Tech Tip: Programmatically disable sorting in listbox
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: March 16, 2015
Listbox columns have the ability to be sorted if the following conditions are fulfilled.
Columns in the listbox can also disable sorting programmatically. To do so, in the listbox's On Header Clicked form event; return -1 to prevent the sort:
To programtically re-enable the sort, $0 can be set to 0.
Below is an example of disabling the first column from being sorted, while allowing other columns to be sorted:
- Listbox display header is checked
- Listbox column has the sortable property checked
- Listbox On header clicked event is checked
Columns in the listbox can also disable sorting programmatically. To do so, in the listbox's On Header Clicked form event; return -1 to prevent the sort:
Case of :(Form event=On Header Click) $0:=-1 //disable sort End case |
To programtically re-enable the sort, $0 can be set to 0.
Below is an example of disabling the first column from being sorted, while allowing other columns to be sorted:
//Listbox Object Method Case of : (Form event=On Header Click) C_TEXT($varName) C_LONGINT($tableNum;$fieldNum) RESOLVE POINTER(Self;$varName;$tableNum;$fieldNum) If ($varName="Header1") $0:=-1 Else $0:=0 end if End Case |