Filtering the grid based on the given purchase order in the Listpage:-
In ListPage we don't have override method. In order to filter the data based on the given input in the field and If you want to initialize some value to the field and based on that you want the grid to display.
When ever a ListPage Form is Opened, initializeQuery() method on the ListPageInteraction class is called.
In order to filter the grid based on the given input in the Listpage form you need to override the initializeQuery() method.
Scenario :- Take a input field in the PurchTableListPage form and based on the Purchase Order entered in the field it should display the grid.
It can be achieved by adding the below code.
Add the below code in initializeQuery() method :-
/* actually we are making a range value empty so that when you open the listpage form the grid will be empty */
else
{
_query.dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchId)).value(SysQuery::valueEmptyString());
}
Now add the below code to the modified method of the Field based on which you want the grid to be filter
public boolean modified()
{
boolean ret;
ret = super();
PurchaseTable_ds.queryBuildDataSource().clearRanges();
/*filtering the grid based on the given purchase order */
if (this.valueStr() != '' )
{
PurchaseTable_ds.queryBuildDataSource().addRange(fieldNum(PurchTable, PurchId)).value(this.valueStr());
PurchaseTable_ds.executeQuery();
}
/* if the input field is empty we are changing the range from PurchId to RecId and searching for RecId with a value "0", which is always not present. This will help you to show an empty grid whenever user enter a null value and search for the list*/
else
{
PurchaseTable_ds.queryBuildDataSource().addRange(fieldNum(PurchTable, RecId)).value("0");
PurchaseTable_ds.executeQuery();
}
return ret;
}
In ListPage we don't have override method. In order to filter the data based on the given input in the field and If you want to initialize some value to the field and based on that you want the grid to display.
When ever a ListPage Form is Opened, initializeQuery() method on the ListPageInteraction class is called.
In order to filter the grid based on the given input in the Listpage form you need to override the initializeQuery() method.
Scenario :- Take a input field in the PurchTableListPage form and based on the Purchase Order entered in the field it should display the grid.
It can be achieved by adding the below code.
Add the below code in initializeQuery() method :-
/* actually we are making a range value empty so that when you open the listpage form the grid will be empty */
else
{
_query.dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchId)).value(SysQuery::valueEmptyString());
}
Now add the below code to the modified method of the Field based on which you want the grid to be filter
public boolean modified()
{
boolean ret;
ret = super();
PurchaseTable_ds.queryBuildDataSource().clearRanges();
/*filtering the grid based on the given purchase order */
if (this.valueStr() != '' )
{
PurchaseTable_ds.queryBuildDataSource().addRange(fieldNum(PurchTable, PurchId)).value(this.valueStr());
PurchaseTable_ds.executeQuery();
}
/* if the input field is empty we are changing the range from PurchId to RecId and searching for RecId with a value "0", which is always not present. This will help you to show an empty grid whenever user enter a null value and search for the list*/
else
{
PurchaseTable_ds.queryBuildDataSource().addRange(fieldNum(PurchTable, RecId)).value("0");
PurchaseTable_ds.executeQuery();
}
return ret;
}
Awesome Information Eshanth :)
ReplyDeleteThanks Raghu :)
ReplyDelete