Home | Previous Lesson: Custom Sort Next Lesson: Find & Replace Service |
To enable the filter service, just write the following line.
dw_product.of_SetFilter( TRUE)
Some programmers write this code in the constructor event of the DataWindow. It would be better when written in the pfc_PostOpen event of the specific window. When the later method is followed, the window is opened first and the script written in the pfc_PostOpen window is executed later. This is because, the event is posted instead of being triggered. By this the user will see the window faster.
If you run the application, PFC displays the standard filter dialog box. Similar to the sort service, PFC has different dialog boxes for the filter service. The following asks the PFC to use its dialog box.
dw_product.inv_filter.of_SetStyle(1)
The following picture is the result of the above code.
Its similar to PowerBuilder's default filter dialog box with the addition of "Values". PFC retrieves the distinct values of the column selected in the Columns tab page. If you have a DataWindow with thousands of rows, don�t use this style, instead choose the default one. PFC retrieves the values in this tab page using the embedded SQL, it doesn�t share the values from the DataWindow. That means, it uses considerable amount of resources.
If you set the transaction object of this DataWindow in a normal way, dw_product.SetTransObject( SQLCA), PFC won�t display the values in this tab page. Set the transaction object using: dw_product.of_SetTransObject(SQLCA).
There is one more PFC filter dialog box:
dw_product.inv_filter.of_SetStyle(2)
This is DDLB style filter dialog box. As you type in the third DDLB, PFC finds the nearest/matching value and displays the value in the DDLB. The bad part is that, you can�t select a column name, you can only select the values in the third DDLB.
Similar to the sort service, you have the choice of using "Column Header Names"/ "Database Column Names"/ "DataWindow Column Names". You need to call of_SetColumnnameSource() function. If you want to allow the user filtering only on the visible columns, you can restrict him by calling of_SetVisibleOnly(TRUE) function.
In the third style, eventhough it displays the earlier filter criteria, it doesn't fill the bottom portion of the filter criteria box, meaning any criteria you set second time overwrites the first one, it doesn't append to the existing criteria.
Similar to sort service, you can exclude one or more columns from being filtered. However, If you know the column name, you can type it in the filter dialog box, even though it is not shown because of of_setExclude().
If you are using a menu that is inherited from the PFC menu, you don�t have to code in the menu�s clicked event and in the window (other than the code explained above). Moreover, you don�t have to define any user-defined events for the purpose of filter service. Also, you don�t have to destroy the filter service, created by the of_SetFilter( TRUE) function. The PFC takes care of that in the u_dw�s destructor event.
Home | Previous Lesson: Custom Sort Next Lesson: Find & Replace Service |