| Home | Previous Lesson: Sorting On Display Values Rather Than Data Values Next Lesson: Filter Service |
Say, the product_balance column has the following values. The following table shows the results of different sort orders. The user wants the last sort order from left. How do you achieve this using PFC sort service?
|
Ascending Order |
Descending Order |
The Sort Order User Wants |
|
-20 |
20 |
-10 |
|
-10 |
10 |
-20 |
|
0 |
0 |
0 |
|
10 |
-10 |
10 |
|
20 |
-20 |
20 |
The code is simple. You need to write:
dw_product.inv_sort.of_setsort(&
"sign(product_balance) A, abs(product_balance) A")
dw_product.inv_sort.of_sort()
Whenever you open the sort criteria dialog box, it displays the current sort criteria. This applies to both PowerBuilder's default one as well as all PFC sort styles. However, when you sort a DataWindow using expressions like the above, the sort criteria dialog box doesn't display the current sort criteria at all.
If you are using a menu that is inherited from PFC's m_sheet, then View > Sort menu option takes care of sorting the current DataWindow. Incase if you want to sort from somewhere else, you need to either call as shown below or you need to code similar to the one shown in 'Custom Sort' section.
dw_product.Event pfc_SortDlg()
If you want to find out whether the sort service is using display values or data values to sort, call:
dw_product.inv_sort.of_GetUseDisplay()
| Home | Previous Lesson: Sorting On Display Values Rather Than Data Values Next Lesson: Filter Service |