如果想重写系统的某个数据源下的字段的Lookup,则可以在此控件下重写Lookup方法,不调用其父级数据源下字段的looku即可。
以下是一个关于重写Lookup方法的例子,可参考:
[FormControlEventHandler(formControlStr(SalesTable, SalesLine_ItemId), FormControlEventType::Lookup)] public static void SalesLine_ItemId_OnLookup(FormControl sender, FormControlEventArgs e) { query query ; QueryBuildDataSource qbds; container con; SalesTable salesTable; SalesLine salesline,origSalesLine; FormStringControl stringControlItemId; FormRun element = sender.formRun(); FormObjectSet dateSource = element.dataSource(); sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), sender); salesline = dateSource.cursor(); salesTable = salesline.salesTable(); query = new query(); qbds = query.addDataSource(tableNum(InventTable)); //如果有原订单存在,则新建物料时过滤下拉 if(salesTable.OrigSalesId && SalesTable::checkExist(salesTable.OrigSalesId)) { while select ItemId from origSalesLine where origSalesLine.SalesId == salesTable.OrigSalesId { con += origSalesLine.ItemId; } qbds.addRange(fieldnum(InventTable,ItemId)).value(con2Str(con)); } sysTableLookup.parmQuery(query); sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId));//下拉显示的字段 sysTableLookup.performFormLookup(); FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs; ce.CancelSuperCall();//不调用其父类的Lookup,数据源中的Lookup。 }