Functions ›› MTblSort... ››
Parent Previous Next

bOk = MTblSortEx( hWndTbl, hWndaCols[*], naColSortFlags[*], nMinRow, nMaxRow, nMinRowLevel, nMaxRowLevel, nSuperiorRow )

Extended sorting with the facility to define the rows to sort with any combination of their position, level and superior row.

Window Handle: Handle of the table

Array of Window Handle: Handles of the columns to sort.

Array of Number: Column sort flags.

Number: First row ( including ) or TBL_Error to sort from the begin of the table

Number: Last row ( including ) or TBL_Error to sort to the end of the table

Number: Minimum row level ( including ) or <= 0 to sort from level 0

Number: Maximum row level ( including ) or < 0 to sort all row levels >= the minimum row level

Number: If you specify a valid parent row, only rows that are descendant of that row are sorted

Boolean: TRUE if successful or FALSE if an error occurs

In this example only the direct child rows of a parent row are sorted by two columns, the first ascending with default data type and the second descending with custom data type. We assume that the second column contains month names, e.g. "January" or "December".

If NOT SalArrayIsEmpty( hWndaCols )
 Call SalArraySetUpperBound( hWndaCols, 1, -1 )
Set hWndaCols[0] = col1
Set naSortFlags[0] = MTS_ASC | MTS_DT_DEFAULT
Set hWndaCols[1] = col2
Set naSortFlags[1] = MTS_DESC | MTS_DT_CUSTOM
Set nRowLevel = MTblGetRowLevel( hWndTbl, nParentRow ) + 1
Call MTblSortEx( hWndTbl, hWndaCols, naSortFlags, TBL_Error, TBL_Error, nRowLevel, nRowLevel, nParentRow )
Child Table: tbl1
 Message Actions:
   On MTM_QuerySortValue
     Set hWndCol = SalNumberToWindowHandle( wParam )
     SalGetItemName( hWndCol, sItemName )
     If sItemName = "col2"
       ! GetMonthNr returns the month number, e.g. 1 for "January" and 12 for "December"
       Return GetMonthNr( col2 )      

Split rows are not supported.
If you're using row hierarchy, you can restore the hierarchical structure with a call to MTblSortTree.

See also
Extended sorting

Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator