I have a grid who display all records of a table , i want to filter records by two date
how can i produce for that
Thank you
I have a grid who display all records of a table , i want to filter records by two date
how can i produce for that
Thank you
Could you be a bit more specific?
Ahmed,
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;
}
Harendra Vepati replied on Fri, Jun 13 2014 6:56
Hi Harendra
first thank you for you replay and is’t work , when i excute form he don’t display all data and when i enter the value of date for filtring he don’t show result of request
datasource has many records inserted.
There is the solution of my issue using SysQuery::range() to specify a range of values:
public void executeQuery()
{
QueryBuildRange qbrName;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
Range range;
;
// specify whatever table you need to filter
qbds = this.query().dataSourceTable( tablenum(AALReportTable) );
qbr = qbds.addRange( fieldnum(AALReportTable, DateDebut) );
// suppose fromDate and toDate are declared somewhere
qbr.value( SysQuery::range( dateD.dateValue(), dateF.dateValue()) );
super();
}