Friday, 4 March 2016

Filter Datasource in form

Class Declaration of Form :

QueryBuildRange qbrYear, qbrMake, qbrModel;

Data Source Init method

public void init()
{
    super();
    qbrYear =   this.query().dataSourceName('FitmentGuide').addRange(fieldNum(FitmentGuide,Year));
    qbrMake =   this.query().dataSourceName('FitmentGuide').addRange(fieldNum(FitmentGuide,Make));
    qbrModel =   this.query().dataSourceName('FitmentGuide').addRange(fieldNum(FitmentGuide,Model));
}

Data Source Execute Query

public void executeQuery()
{
    if(YearFilter.valueStr())
        qbrYear.value(queryValue(YearFilter.valueStr()));
    else
        qbrYear.value(queryValue(null));
    if(MakeFilter.valuestr())
        qbrMake.value(queryValue(MakeFilter.valuestr()));
    else
        qbrMake.value(queryValue(null));
    if(ModelFilter.valuestr())
        qbrModel.value(queryValue(ModelFilter.valuestr()));
    else
        qbrModel.value(queryValue(null));

    super();
}



2nd Way : If you dont have  data source for which you want to keep range but it is related to the tables in form 

Class Declaration of Form :

QueryBuildDataSource            qbrmatchingorders,qbrsalestable
Data source Init method ( to which you want to add relation and range)

public void init()
{
    super();
    qbrmatchingorders   =   MatchingOrders_q.dataSourceTable(tableNum(MatchingOrders));
    qbrsalestable   =   qbrmatchingorders.addDataSource(tableNum(SalesTable));
    qbrsalestable.joinMode(JoinMode::ExistsJoin);
    qbrsalestable.relations(true);
}

Data Source Execute Query

public void executeQuery()
{
    QueryBuildRange                 qbrmatchbackkeycode;
    qbrmatchbackkeycode = qbrsalestable.addRange(fieldNum(SalesTable,MatchbackKeycode));
    qbrmatchbackkeycode.value(queryValue(""));
    super();
}



No comments:

Post a Comment