Command PV SORT ONE

4D View

PV SORT ONE

version 6.8


PV SORT ONE (area; left; top; right; bottom; direction; key; order)

ParameterTypeDescription
areaLongint4D View area
leftLongintLeft column number
topLongintTop row number
rightLongintRight column number
bottomLongintBottom row number
directionInteger0 = Row sort; 1 = Column sort
keyLongintColumn or row containing the values to sort
orderInteger0 = Ascending; 1 = Descending

Description

The PV SORT ONE command sorts the contents of the selection delimited using left, top, right, and bottom in relation to values contained in the row or column key, in the order defined by order.

direction indicates if the sort should arrange rows or columns:

• If you pass 0, you arrange rows depending on the values of the row key.

• If you pass 1, you arrange columns depending on the values of the column key.

This command only operates with static data.

Dynamic areas (arrays and linked fields) must be sorted using 4D commands — the principle consists of sorting the source. An example of sorting dynamic columns linked to fields when the header is clicked on is supplied in the description of the PV GET CELL FIELD command. Note that sorting is not possible on picture type arrays and fields nor on calculated columns (that call a callback method and display its result).

Example

This example allows an ascending sort of static columns by clicking on the column header. The area only contains static columns.

• 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
   C_BOOLEAN($0)
   C_LONGINT($1;$2;$3;$4;$5;$6)

   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

See Also

PV SORT COLUMN, PV SORT MANY.