Kbase 16496: ADM1. How To Sort A Browse By Clicking On The Column Labels?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/17/2004 |
|
Status: Verified
GOAL:
How to use the searching capabilities of a browse widget, to allow your users to simply click on the column label of any field in your browse, and have the data in the browse widget sorted by the column the user clicks on.
GOAL:
How To Sort A Browse By Clicking On The Column Labels?
FACT(s) (Environment):
Progress 8.x
Progress ADM1
FIX:
You may need to know this if your users want this kind of simple sorting mechanism when browsing through data.
In this example we are using the SPORTS database and a Regular Browser Widget that contains the following fields:
- Customer.Cust-Num
- Customer.Name
- Customer.Sales-Rep
- Customer.State
- Customer.Country
First off, make sure that all of the fields in your browse widget are enabled.
Second, in local-initialize (for a SmartBrowse) or after the enable_UI procedure call in the Main Block (for a normal window), insert code similar to the following:
ASSIGN Customer.Cust-Num :READ-ONLY IN BROWSE {&BROWSE-NAME} = TRUE
Customer.Name :READ-ONLY IN BROWSE {&BROWSE-NAME} = TRUE
Customer.Sales-Rep:READ-ONLY IN BROWSE {&BROWSE-NAME} = TRUE
Customer.State :READ-ONLY IN BROWSE {&BROWSE-NAME} = TRUE
Customer.Country :READ-ONLY IN BROWSE {&BROWSE-NAME} = TRUE.
This code will allow the user the click on the column label for each field to initiate the START-SEARCH event but will not allow "cell" editing (i.e. an updatable browse). This code may be optional depending on whether you want the user to be able to update the contents of the browse directly or not.
Third, in the START-SEARCH trigger for the browse widget, insert code similar to the following:
DEFINE VARIABLE ColumnHandle AS HANDLE NO-UNDO.
ASSIGN ColumnHandle = {&BROWSE-NAME}:CURRENT-COLUMN.
APPLY 'END-SEARCH' TO {&BROWSE-NAME}.
CASE ColumnHandle:NAME:
WHEN 'Cust-Num' THEN /* Cust-Num Field Selected By User? */
OPEN QUERY {&BROWSE-NAME}
FOR EACH Customer NO-LOCK BY Customer.Cust-Num.
WHEN 'Name' THEN /* Name Field Selected By User? */
OPEN QUERY {&BROWSE-NAME}
FOR EACH Customer NO-LOCK BY Customer.Name.
WHEN 'Sales-Rep' THEN /* Sales-Rep Field Selected By User? */
OPEN QUERY {&BROWSE-NAME}
FOR EACH Customer NO-LOCK BY Customer.Sales-Rep.
WHEN 'State' THEN /* State Field Selected By User? */
OPEN QUERY {&BROWSE-NAME}
FOR EACH Customer NO-LOCK BY Customer.State.
WHEN 'Country' THEN /* Country Field Selected By User? */
OPEN QUERY {&BROWSE-NAME}
FOR EACH Customer NO-LOCK BY Customer.Country.
END CASE.