Log In    |    Knowledge Base    |    4D Home
Tech Tip: Column or row header sorting in 4D View v6.8.1
PRODUCT: 4D View | VERSION: 6.8.1 | PLATFORM: Mac & Win
Published On: January 3, 2003

There have been some important changes to 4D View v6.8.1. Among these changes is the management of sorting when clicking on column or row headers.

Under 4D View v6.8.0, you would do something like:

$sortAllowed:=1 `1=allowed 0=not-allowed
PV SET COLUMN HEADER ($area;1;"Create Date";$sortAllowed)

This is no longer valid under 4D View v6.8.1. Under 4D View v6.8.1, to implement header or column sorts you must consider whether the data is static or dynamic.

- For static data:

We begin by installing the HeaderSortMethod callback method, that will be called in the event of a click in the area:

PV ON EVENT (area;pv on clicked;"HeaderSortMethod")

The HeaderSortMethod method catches any clicks on the column headers and sorts the corresponding data (from rows 1 to 25) in ascending order:

`HeaderSortMethod method
If ($5=0) `If the click takes place on a header
 $0:=True `Blocks the event
 PV SORT ONE (area;$4;1;$4;25;1;$4;0) `Ascending sort of the selected column
End if

For further details, Please see:

- For Dynamic Data:

We begin by installing the EventMethod callback method that will be called in the event of a click in the area:

PV ON EVENT(area;pv on clicked;"EventMethod")

This statement catches any clicks in the area. The EventMethod method will enable us to detect clicks in the column headers and to sort the data as a consequence.

`EventMethod Method
If($5=0) `If the click takes place in a header
 :$0:=True `Cancels the event
 :$PV GET CELL FIELD(area;$4;1;$tableNum;$fieldNum) `Data to be sorted
 :$ORDER BY(Table($tableNum)->;Field($tableNum;$fieldNum)->;>) `Sorting 4D data
End if `Linked values in the columns are automatically sorted

For further details, Please see:

- Please view the 4D View Upgrade manual for other important changes.

4D_View_681_Upgrade.pdf can be found found at :