1.常规
public void lookup()
{Query q = new Query();QueryBuildDataSource queryBuildDataSource;SysTableLookup sysTableLookup;QueryBuildRange;sysTableLookup = SysTableLookup::newParameters(tableNum(Table), formControl);queryBuildDataSource = q.addDataSource(tableNum(Table));queryBuildDataSource.addRange(fieldNum(Table,field)).value();sysTableLookup.addLookupField(fieldNum(Table, field));//此处展示表方法 //注意点method方法如果涉及Table里面的多个字段,需要都放在lookup上显示,不然method最终显示有误sysTableLookup.addLookupMethod(tableMethodStr(Table, method));sysTableLookup.parmQuery(q);//sysTableLookup.parmUseLookupValue(false);排序时使用 //注意:排序需要使用addOrderByField, //使用addSortField没有任何效果sysTableLookup.performFormLookup();
}
2.常规lookup有时无法实现dsp字段的筛选,需要使用临时表
tmp.clear();
while select VendTablejoin DirPartyTablewhere VendTable.Party == DirPartyTable.RecId{if(DirPartyTable.type() == DirPartyType::Person){tmp.AccountNum = VendTable.AccountNum;tmp.Name = DirPartyTable.Name;tmp.insert();}}
SysTableLookup = SysTableLookup::newParameters(tableNum(TableTmp),_formControl);
qbds = q.addDataSource(tableNum(TableTmp));
SysTableLookup.addLookupfield(fieldNum(TableTmp,field));
sysTableLookup.parmQuery(q);
SysTableLookup.parmTmpBuffer(tmp);//注意
sysTableLookup.performFormLookup();
3.系统标准窗体无法直接更改
[FormControlEventHandler(formControlStr(LedgerJournalTransDaily, LedgerJournalTrans_SalesContractNo), FormControlEventType::Lookup)]
public static void LedgerJournalTrans_SalesContractNo_OnLookup(FormControl sender, FormControlEventArgs e)
{FormRun fr = sender.formRun();FormDataSource fds = fr.dataSource(formDataSourceStr(LedgerJournalTransDaily, LedgerJournalTrans));//lookup代码...//根据各自需求添加一下代码,用于清空标准的lookup(已知作用:可以清除表关系的影响)FormControlCancelableSuperEventArgs formControlCancelableSuperEventArgs = e as FormControlCancelableSuperEventArgs;formControlCancelableSuperEventArgs.CancelSuperCall();}