我正在尝试使用2个连接表进行自定义查找(在.Net中):
AxLookup nameLookup = e.LookupControl;
Proxy.QueryBuildDataSource emplTable = null;
Proxy.QueryBuildDataSource dirPartyTable = null;
using (Proxy.SysDataSetBuilder sysDataSetBuilder = proxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "EmplTable")))
{
nameLookup.LookupDataSet = new DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
}
using (Proxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
{
emplTable = query.dataSourceNo(1);
dirPartyTable = emplTable.addDataSource(TableMetadata.TableNum(this.AxSession, "DirPartyTable"));
dirPartyTable.clearLinks();
dirPartyTable.addLink(TableDataFieldMetadata.FieldNum(this.AxSession, "EmplTable", "PartyId"), TableDataFieldMetadata.FieldNum(this.AxSession, "DirPartyTable", "PartyId"));
dirPartyTable.joinMode = 6; //should be an exists join
}
nameLookup.LookupDataSet.Init();
nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["EmplId"]));
nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["DirPartyTable!Name"])); //not working!!
nameLookup.SelectField = "EmplId";
现在当我使用查找时,它让我对DirPartyTable中的Name字段出错(找不到键)有人知道如何在连接表中添加lookupfield吗?
我确定连接工作正常,在连接表上进行了一些其他范围的查找(并且第二个表上没有查找字段),这样就行了。
感谢任何帮助!
答案 0 :(得分:1)
以下博客文章对此进行了讨论: http://palleagermark.blogspot.com/2009/12/data-set-lookups-on-enterprise-portal.html
答案是你不能使用带有AxLookup控件连接的数据源,因为它只支持一个DataSetView,并且如果你有多个DataSetView就会抛出这个异常。