X++双向关联查询数据,初始化下拉选项

static client void lookupInfuseBOMId(FormStringControl   _ctrl,ItemId _itemId)


{

   //传入要查询的表
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(BomTable), _ctrl);
    Query                   query;
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildDataSource    queryBuildDataSourceSite;
    QueryBuildDataSource    qbdBomVersion;

    QueryBuildRange         queryBuildRange;
    QueryBuildRange         qbrVesionRange;
    ;
    query = new Query();

    queryBuildDataSource = query.addDataSource(tablenum(BomTable));

    qbdBomVersion=queryBuildDataSource.addDataSource(tablenum(BomVersion));
    qbdBomVersion.joinMode(JoinMode::ExistsJoin);
    qbdBomVersion.addLink(fieldnum(BomTable,BomId),fieldnum(BomVersion,BomId));

    queryBuildDataSourceSite = qbdBomVersion.addDataSource(tablenum(JaxBomType));
    queryBuildDataSourceSite.joinMode(JoinMode::ExistsJoin);
    queryBuildDataSourceSite.addLink(fieldnum(BomVersion,JaxBoMTypeId ), fieldnum(JaxBomType, JaxBoMTypeId));

    queryBuildRange=queryBuildDataSourceSite.addRange(fieldnum(JaxBomType,isInfuseWax));
    queryBuildRange.value(QueryValue(NoYes::Yes));


    qbrVesionRange=qbdBomVersion.addRange(fieldnum(BomVersion,ItemId));
    qbrVesionRange.value(_itemId);

 

    //初始化要显示的栏位

    sysTableLookup.addLookupfield(fieldnum(BomTable, BomId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, Name));
    sysTableLookup.addLookupfield(fieldnum(BomTable, SiteId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, ItemGroupId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, JaxBOMTypeId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, JaxGoldContentId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, JaxStoneTypeId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, JaxPartsTypeId));
    sysTableLookup.addLookupfield(fieldnum(BomTable, JaxEditionId));

    //return sysTableLookup;
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

 

 

  调用位置,

     重写数据源的lookup方法

public void lookup(FormControl _formControl, str _filterStr)
{
    //super(_formControl, _filterStr);
    ;
    BOMTable::lookupInfuseBOMId(_formControl,BOMVersion.ItemId);
}

 

  用户在使用下拉列表的时候就会调用此方法

你可能感兴趣的:(X++双向关联查询数据,初始化下拉选项)