Kbase P73465: How to sort a Browse by clicking in the column label
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/16/2011 |
|
Status: Verified
GOAL:
How to sort a Browse by clicking in the column label
GOAL:
How to Use Browse Column Labels to Sort Browse Query
GOAL:
How to change order by a specific column of the browser
FACT(s) (Environment):
All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x
FIX:
This solution describes how to program a browse widget to allow users to click on a browse column and have the browse query re-open and sort on the selected column. It is worth noting that after the browse is created the first two steps are not necessary in OpenEdge 10.x if the browse attribute ALLOW-COLUMN-SEARCHING is checked ON. In addition, in OpenEdge 10.x the column attribute SORT-ASCENDING can be manipulated to indicate in the column heading the order of the sort.
1) Create a browse widget and make at least one of its fields updatable. This example uses the Customer table and displays CustNum, Name, and SalesRep fields. Name is enabled.
2) Disable the enabled Name field in the window's MAIN BLOCK after
RUN enable_UI:
ASSIGN name:READ-ONLY IN BROWSE BROWSE-1 = TRUE.
This will only need to be done if you want the browser to be read-only. If you have an updatable browser, enable the appropriate fields and leave them enabled.
3) Create a START-SEARCH trigger for the browse with the following code:
A. START-SEARCH trigger code for versions 9.x and higher:
DO:
DEFINE VARIABLE hSortColumn AS WIDGET-HANDLE.
DEFINE VARIABLE hQueryHandle AS HANDLE NO-UNDO.
hSortColumn = BROWSE BROWSE-1:CURRENT-COLUMN.
hQueryHandle = BROWSE BROWSE-1:QUERY.
hQueryHandle:QUERY-CLOSE().
hQueryHandle:QUERY-PREPARE("FOR EACH CUSTOMER NO-LOCK BY " + hSortColumn:NAME).
hQueryHandle:QUERY-OPEN().
END.
A. START-SEARCH trigger code for versions 8.x and lower:
DO:
DEFINE VARIABLE hSortColumn AS WIDGET-HANDLE.
hSortColumn = BROWSE-1:CURRENT-COLUMN.
CASE hSortColumn:LABEL:
WHEN "CustNum" THEN
OPEN QUERY BROWSE-1 FOR EACH customer BY CustNum.
WHEN "Name" THEN
OPEN QUERY BROWSE-1 FOR EACH customer BY Name.
WHEN "SalesRep" THEN
OPEN QUERY BROWSE-1 FOR EACH customer BY SalesRep.
END CASE.
END.
When this example window is run, clicking on a browse column label
will re-open the browse query and sort the query based on the label
chosen.