sort list by header


Clarion does not provide the ability to sort by columnheaders, but it is very easy to do. This example assumes a 2 column browse. Each column has a index associated with it in the dictionary. The first column is CODE and the second column is DESCRIPTION.

Define this local variable
Loc:SortColumn       BYTE

Change the header column on the listbox
From "CODE" 

to "CODE •"

 - This addes the sort order indicator to CODE

Add the following 2 Conditional Behaviours to the browse control
If Loc:SortColumn = 1 then set browse key is Cus:KeyCode

If Loc:SortColumn = 2 then set browse key is Cus:KeyName

Embed this in ThisWindow.Init, After opening Window
?list{prop:Alrt} = MouseLeftUp
(Assuming ?list is the name of the control)

Embed this in the Window's Alert key embed:
  if keycode() = MouseLeftUp
    if BRW2.ILC.GetControl(){proplist:MouseDownRow} = 0 and BRW2.ILC.GetControl(){proplist:MouseDownField} <> 0
       Loc:SortColumn = ?List{Proplist:MouseDownField}
       Case ?List{Proplist:MouseDownField}
       Of 1
          ?List{PROPList:Header,1} = 'CODE •'
          ?List{PROPList:Header,2} = 'NAME'
       Of 2
          ?List{PROPList:Header,1} = 'CODE'
          ?List{PROPList:Header,2} = 'NAME •'

(Assuming BRW2 is the name of the browse object)

Schreibe einen Kommentar