Hi Marko,
You can extend the SysTableLookup class. This class uses container to store
fieldId and returmItem values, to create a lookup grid.
If you look at buildGrid function of this class, you can see :
[fieldId, returnItem, method] = conpeek(lookupItems, i);
This means that : get the i'th item of container and set values to fieldId,
returnItem and method variables.
After that, you can see this lines in the same method :
if (!method)
{
formBuildControl =
_formBuildGridControl.addDataField(_formBuildDataSource.id(), fieldId);
.
This is the critical part! You used addLookupField method to insert
fieldId and returnItem values to container. And AX creates a
formBuildControl object belongs to your fieldId. When you look at the
methods of formBuildControl, you can't see the width() method! But you can
solve this problem, too.
If you want to try the solution, let's continue to these steps in
SysTableLookup class :
*1.* Extend addLookupField method, or write a new method :
void addLookupfield(fieldId _fieldId, boolean _returnItem = false,int
_width=0)
{
lookupItems += [[_fieldId, _returnItem,_width]];
}
2. Extend buildGrid method to use width value :
protected FormBuildGridControl buildGrid(FormBuildGridControl
_formBuildGridControl,
FormBuildDataSource
_formBuildDataSource)
{
FormBuildControlformBuildControl;
Object obj;
boolean returnItem;
boolean method;
int fieldId;
int i;
int width;
;
for (i = 1; i = conlen(lookupItems); i++)
{
[fieldId, returnItem,width, method] = conpeek(lookupItems, i);
if (!method)
{
formBuildControl =
_formBuildGridControl.addDataField(_formBuildDataSource.id(), fieldId);
if(width != 0)
{
obj = formBuildControl;
obj.width(width);
}
if (i == 1 || returnItem)
{
controlIdx = formBuildControl.id();
lookupField = fieldId;
}
.
I tested it and it is working pretty.. But it can be necessary another test
scenarios, because we changed the execution of system class.
If you want to test this,you can give width property on third parameter. If
you don't, standart width will be used.
sysTableLookup.addLookupfield(fieldNum(CustTable, AccountNum),true,*150*);
I hope, this method can help you. If you decide to use it, please test
carefoully.
Best regards,
Anil Ozay
MVP Dynamics AX
On 2/6/07, Marko Salonen [EMAIL PROTECTED] wrote:
In 06/02/07, Amit Jain [EMAIL PROTECTED] amitjain_in%40yahoo.com
wrote:
Cant you do this, on your field ? Why do you want to change properties
from
lookup method?
On the field, where?
[Non-text portions of this message have been removed]