4D v13

PV SORT ONE

Home

 
4D View v13
PV SORT ONE

PV SORT ONE 


 

PV SORT ONE ( area ; left ; top ; right ; bottom ; direction ; key ; order ) 
Parameter Type   Description
area  Longint in 4D View area
left  Longint in Left column number
top  Longint in Top row number
right  Longint in Right column number
bottom  Longint in Bottom row number
direction  Integer in 0 = Row sort; 1 = Column sort
key  Longint in Column or row containing the values to sort
order  Integer in 0 = Ascending; 1 = Descending

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

 
PROPERTIES 

Product: 4D
Theme: PV Cell manipulation
Number: 15975

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D View 6.8

 
SEE ALSO 

PV SORT COLUMN
PV SORT MANY