Tuesday 17 June 2014

Date range filter in the grid in ax 2012

follow the below process,

Step-1:
Go to classdeclaration and declare a queryBuildRange object

public class FormRun extends ObjectRun
{
    QueryBuildRange qbr1,qbr2;
}

Step-2:

Override the init() method od DATASOURCE - Please note after super() ur range should be defined as your datasource will get initialized after super()

public void init()

{

    super();

    qbr1 = this.query().dataSourceNo(1).addRange(fieldnum(tablename, fieldname1));

    qbr2 = this.query().dataSourceNo(1).addRange(fieldnum(tablename, fieldname2));

}

Step-3:

Override the executeQuery() method on datasource - should be before super()

public void executeQuery()

{

    ;

qbr1.value(queryValue(ConfirmedDate.dateValue())); // set control autodeclaration to yes and use control name.datevalue() here

 qbr2.value(queryValue(RequestedDate.dateValue()));  // set control autodeclaration to yes and use control name.datevalue() here

 super(); // will retrive all the records from the table and shows it on the grid

}

Step-4:

Finally on the control event

Go to date controls >> OverRide the modified method and add the following code after super()

public boolean modified()

{

    boolean ret;

    ret = super();

    datasourcename_ds.executeQuery();

    return ret;

}

No comments:

Post a Comment