Вы находитесь на странице: 1из 5

Building a tree lookup

1. In the AOT, create a new form named BudgetModelLookup. Set its design properties
as follows:

Property Value
Frame Border
WindowType Popup

2. Add a new Tree control to the design, with the following properties:

Property Value
Name ModelTree

3. Add the following line to the form's class declaration:


BudgetModelTree budgetModelTree;

4. Override the form's init() method with the following code:


public void init()
{
FormStringControl callingControl;
callingControl = SysTableLookup::getCallerStringControl (this.args());
super();
budgetModelTree = BudgetModelTree::construct(ModelTree, callingControl.text());
budgetModelTree.buildTree();
}

5. Override the mouseDblClick() and mouseUp() methods of the ModelTree control


with the following code, respectively:
public int mouseDblClick(int _x, int _y, int _button, boolean _ctrl, boolean _shift)
{
int ret;
FormTreeItem formTreeItem;
BudgetModel budgetModel;
ret = super(_x, _y, _button, _ctrl, _shift);
formTreeItem = this.getItem(this.getSelection());
select firstOnly SubModelId from budgetModel
where budgetModel.RecId == formTreeItem.data();
element.closeSelect(budgetModel.SubModelId);
return ret;
}
public int mouseUp(int _x, int _y, int _button, boolean _ctrl, boolean _shift)
{
int ret;
ret = super(_x, _y, _button, _ctrl, _shift);
return 1;

6. The form should look similar to the following screenshot:

7. In the AOT, open the BudgetModel table, and change its lookupBudgetModel()
method with the following code:

public static void lookupBudgetModel(FormStringControl _ctrl, boolean _showStopped = false)


{
Args args;
Object formRun;
args = new Args();
args.name(formStr(BudgetModelLookup));
args.caller(_ctrl);
formRun = classfactory.formRunClass(args);
formRun.init();
_ctrl.performFormLookup(formRun);
}

8. To see the results, open Budgeting | Common | Budget register entries. Start
creating a new entry by clicking on the Budget register entry button in the action
pane, and expand the Budget model lookup:
Look up Methods

Lookup() Method

Implement this code in the lookup() method of the field where you need the lookup to be displayed.

NS: The same code can be written in three places to achieve the lookup.

1) Under AOT->Table->Method and call this method from the form design where you want to display the
lookup.

2) Form->Datasource->Table->Field->method

3) Form->Design->Field->Method.

public void lookup()

uerWordFieldMapping uerWordFieldMappingLocal;

SysTableLookup sysTableLookup;

Query query;

QueryBuildDataSource qbd;

// Instantiate sysTableLookup object using table which will provide the visible fields

sysTableLookup = SysTableLookup::newParameters(tablenum(uerWordMergeFieldList),this);
uerWordFieldMappingLocal = element.ParentFormValue();

query = new Query();

qbd = query.addDataSource(tablenum(uerWordMergeFieldList));

qbd.addRange(fieldnum(uerWordMergeFieldList,TableName)).value(uerWordFieldMappingLocal.TableN
ame);

// Specify the fields to show in the form

sysTableLookup.addLookupfield(fieldnum(uerWordMergeFieldList,uerWordMergeFieldName));

// Set the query to be used by the lookup form

sysTableLookup.parmQuery(query);

//

sysTableLookup.performFormLookup();

LookUp on datasource level :

public void lookup(FormControl _formControl, str _filterStr)

SysTableLookup sysTableLookup ;

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;

sysTableLookup =
SysTableLookup::newParameters(tableNum(OMInternalOrganization),_formControl);

queryBuildDataSource = query.addDataSource(tableNum(OMInternalOrganization));
sysTableLookup.addLookupfield(fieldNum(OMInternalOrganization, Name));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

Вам также может понравиться