How to achieve dialog with lookup control
How to create a dialog with the lookup as a control, the other control SalesId ItemId lookup is the only thing that SalesId.
Done as follows.
1.declare control by extended data type to use.
class LookupDialog extends RunBase { FormStringControl SalesIdCtrl, ItemIdCtrl; }
2. Creation dialog.
protected Object dialog(Dialog dialog, boolean forceOnClient) { DialogRunBase ret; ; ret = super(dialog, forceOnClient); ret.caption('Costing report by order'); SalesIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'SalesId'); SalesIdCtrl.extendedDataType(extendedTypeNum('SalesId')); ItemIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'ItemId'); ItemIdCtrl.extendedDataType(extendedTypeNum('ItemId')); return ret; }
3.Set the control can not override method at runtime.
public void dialogPostRun(DialogRunbase dialog) { ; super(dialog); dialog.dialogForm().formRun().controlMethodOverload(true); dialog.dialogForm().formRun().controlMethodOverloadObject(this); SalesIdCtrl = dialog.dialogForm().formRun().design().controlName('SalesId'); ItemIdCtrl = dialog.dialogForm().formRun().design().controlName('ItemId'); }
4.Creating lookup method.
void ItemId_lookup() { Query query = new Query(); SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SalesLine), SalesIdCtrl); ; sysTableLookup.addLookupField(fieldNum(SalesLine, ItemId)); sysTableLookup.addLookupField(fieldNum(SalesLine, Name)); query.addDataSource(tableNum(SalesLine)).addRange(fieldNum(SalesLine,SalesId)).value(SalesIdCtrl.text()); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
5.Detailed method other
public container pack() { return conNull(); } public boolean unpack(container packedClass) { return true; } static void main(Args _args) { LookupDialog test1 = new LookupDialog(); ; if (test1.prompt()) { test1.run(); } }