我正在尝试在我创建的网格中联接多个数据源。 网格位于案例详细信息窗体中,它使用与网格上其他一些组相同的表。 因此,我必须使用基于数据源名称而不是表名称的连接。
有InventTable(InventTableComplaints( - parent和EcoResProductTranslation(EcoResProductTranslationComplaints( - child。
我正在尝试做的是将此代码添加到子数据源:
public void executeQuery()
{
QueryBuildDataSource qbdsIT, qbdsERPTC;
qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
qbdsERPTC = qbdsIT.addDataSource(tableNum(EcoResProductTranslation), "EcoResProductTranslationComplaint");
qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
qbdsERPTC.joinMode( JoinMode::OuterJoin );
qbdsERPTC.fetchMode( QueryFetchMode::One2One );
super();
}
但它不起作用。 可能吗?
您不在executeQuery
方法中定义表关系,而是在init
方法中执行此操作,该方法只执行一次。如果在表单中定义了数据源(使用InventTableComplaint
作为JoinSource
,使用OuterJoin
作为JoinMode
(,则也不需要在init
方法中执行此操作,但如果没有作为表关系提供,则可能需要定义链接:
public void init()
{
qbdsIT = InventTableComplaint_DS.queryBuildDataSource();
qbdsERPTC = EcoResProductTranslationComplaint_ds.queryBuildDataSource();
qbdsERPTC.clearLinks();
qbdsERPTC.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
super();
}
请注意,每个InventTable
可能存在多个EcoResProductTranslation
记录(每种语言都打开(,因此网格中可能会InventTable
"重复">