- Use conditions
- Sorting a browsing Table or TreeView Table control
- Managing a sorted Table or TreeView Table control
- Sort on a calculated column
- Table or Treeview Table control browsed by programming
- Performing a sort according to the ASCII value
<Table>.Sort (Function) In french: <Table>.Trie Sorts a Table or TreeView Table control on one or more columns (lexicographical sort). Remark: When a control is sorted by <Table>.Sort, the images used to identify the sort direction are not displayed in the columns.
Versions 20 and later New in version 20
// Sort "COL_Designation" and "COL_Price" columns in "TABLE_Product" // "COL_Designation" is sorted in ascending order // "COL_Price" is sorted in descending order TABLE_Product.Sort("COL_Designation", "-COL_Price")
Syntax
Sorting a Table or TreeView Table control on one or more columns identified by their name Hide the details
<Result> = <Table control>.Sort(<Column 1> [, <Column 2> [... [, <Column N>]]])
<Result>: Boolean - True if the sort was performed,
- False otherwise.
<Table control>: Control name Name of control to use. This control can correspond to: - a Table control.
- a TreeView Table control.
<Column 1>: Character string with quotes Name of first column to sort (up to 16 columns). This parameter has the following format:
"[<Direction>]<Column name>"
where:- <Direction> (character) indicates the sort direction:
- "+": ascending sort (by default),
- "-": descending sort.
- <Column name> (character string): name of column to sort.
<Column 2>: Optional character string with quotes Name of the second column to sort (up to 16 columns). This parameter has the following format:
"[<Direction>]<Column name>"
where:- <Direction> (character) indicates the sort direction:
- "+": ascending sort (by default),
- "-": descending sort.
- <Column name> (character string): name of column to sort.
<Column N>: Optional character string with quotes Name of Nth column to sort (up to 16 columns). This parameter has the following format:
"[<Direction>]<Column name>"
where:- <Direction> (character) indicates the sort direction:
- "+": ascending sort (by default),
- "-": descending sort.
- <Column name> (character string): name of column to sort.
Canceling a sort that was previously defined on a memory Table or TreeView Table control Hide the details
<Result> = <Table control>.Sort(<False>)
<Result>: Boolean - True if the sort was canceled,
- False if a problem occurred.
<Table control>: Control name Name of control to use. This control can correspond to: - a memory Table control.
- a memory TreeView Table control.
<False>: Constant False: Keyword used to cancel a sort that was previously defined on a memory Table or TreeView Table control. Remarks Use conditions <Table>.Sort can be used on: - a memory or browsing control with automatic browse ("Automatic browse" option checked in the "Content" tab of control description). For a browsing control, the sort is performed on a single column.
- a single-selection or multiselection control.
Sorting a browsing Table or TreeView Table control A browsing Table or TreeView Table control will be sorted according to the first specified column (syntax 1 and 2). Caution: the column used for the sort must be linked to a key item in the data file used to browse the control. Tip: To sort a browsing Table or TreeView Table control with several columns, use a composite key and ..BrowsedItem:
TableName..BrowsedItem = NAMECOMPOSITEKEY
To cancel a sort in a browsing Table or TreeView Table control, all you have to do is assign an empty string to ..BrowsedItem. Managing a sorted Table or TreeView Table control - When the control is sorted by <Table>.Sort, the additions performed by <Table>.Add, <Table>.AddLine, <Table>.Insert and <Table>.InsertLine take the sort into account.
- When the control is sorted by a mouse click, the additions performed by <Table>.Add, <Table>.AddLine, <Table>.Insert and <Table>.InsertLine ignore the sort.
- The sort is not canceled by <Table>.Display, <Table>.Adjust, TableSeek, <Table>.Count, <Table>.Position, <Table>.Select, <Table>.SelectMinus, <Table>.SelectPlus, <Table>.Delete and <Table>.DeleteAll.
- The sort is canceled if a column is modified (by direct input in the column or by <Table>.Modify and <Table>.ModifyLine) and if it is sorted.
Sort on a calculated column <Table>.Sort should not be used on the calculated columns. Indeed, these columns are calculated when each row is displayed. A sort performed by <Table>.Sort on a calculated column will be valid for the rows already displayed in the table. Table or Treeview Table control browsed by programming <Table>.Sort does not operate on a control browsed by programming. Performing a sort according to the ASCII value A memory zone allows you to perform a sort according to the ASCII value. Example:
MemCreate("MZ") MemAdd("ZM", "abc", "abc") MemAdd("ZM", "ZZZ", "ZZZ") MemAdd("ZM", "zbc", "zbc") MemAdd("MZ", "ééébc", "ééébc") MemAdd("ZM", "AB", "AB") MemAdd("ZM", "CD", "CD") MemAdd("MZ", "çabc", "çabc") MemAdd("ZM", "bbc", "bbc") MemSort("MZ") i is int MemFirst("MZ") WHILE NOT MemOut("MZ") i = MemCurrent("ZM") Trace(MemRetrieve("MZ", i)) // Display in ASCII order MemNext("MZ") END
This page is also available for…
|
|
|