Use the following code to enable PowerFilter on your datawindow:
//Declare instance variable
n_cst_powerfilter inv_powerfilter
//Open event of your window or constructor of your user object
inv_powerfilter = CREATE n_cst_powerfilter
inv_powerfilter.of_SetDatawindow(dw_1)
inv_powerfilter.of_DisplayFilterButtons(TRUE)
//Left button up event on the datawindow passed to of_SetDatawindow
//Declare a new event mapped to pbm_dwnlbuttonup
//This code is used to display the filter drop down
iu_PowerFilter.of_ShowFilterDropDown(dwo)
Additional Implementation Details:
Limit filtering to specific columns:
The default behavior is to provide filtering on all columns and computed fields where the header text object name is the same as the column name + ”_t”. Two optional function calls can also be added after of_SetDatawindow() to override the default behavior:
To limit filtering to specific columns, or if the header text object names do not equal column name + '_t', you may use the following function call:
inv_powerfilter.of_SetColumns({'column1', 'column2', 'column3'})
Displaying custom titles for columns in PowerFilter:
To define the titles of the columns displayed in the dropdown or ToolTip, you can use of_SetTitles(). The parameter count must equal either the number of columns passed in of_SetColumns(), or the number of columns with headers = column name + '_t', if of_SetColumns() is not used.
inv_powerfilter.of_SetTitles({'Title one’, 'Title two', 'Title Three'})
An alternative way to pass values: load an array, then pass the array
String ls_Titles[] = {'Title one', 'Title two', 'Title Three'}
inv_powerfilter.of_SetTitles(ls_Titles)
Re-position buttons in the event that the datawindow control is resized:
In the Resize event of the datawindow control to be filtered, add the following:
inv_powerfilter.event ue_positionbuttons()
Additional Notes:
Verify that your datawindow object’s column header names equal the column names with “_t” appended to them. For example, if you have a column or computed field named “employee”, the header text object must be named “employee_t”. If you do not want to filter on a particular column, then disregard this rule for that column, or use of_SetColumns() and of_SetTitles() as described above.
Copyright © 2023 Werysoft Inc.