PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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 through programming
  • Performing a sort according to the ASCII value
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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 16 and later
Linux This function is now available for WINDEV applications in Linux.
New in version 16
Linux This function is now available for WINDEV applications in Linux.
Linux This function is now available for WINDEV applications in Linux.
Example
// Tri des colonnes "COL_Désignation" et "COL_Prix" du champ "TABLE_Produit"
// La colonne "COL_Désignation" est triée dans l'ordre croissant
// La colonne "COL_Prix" est triée dans l'ordre décroissant
TABLE_Produit.Trie("COL_Désignation", "-COL_Prix")
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 the control to be used. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
<Column 1>: Character string
Name of first column to sort (up to 16 columns). This parameter has the following format:
"[<Sens>]<Nom de la colonne>"

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
Name of the second column to sort (up to 16 columns). This parameter has the following format:
"[<Sens>]<Nom de la colonne>"

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
Name of Nth column to sort (up to 16 columns). This parameter has the following format:
"[<Sens>]<Nom de la colonne>"

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 the control to be used. 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 multi-selection 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 the BrowsedItem property:
NomTable..RubriqueParcourue = NOMCLECOMPOSEE
To cancel a sort in a browsing Table or TreeView Table control, simply assign an empty string to the BrowsedItem property.

Managing a sorted Table or TreeView Table control

Reminder: <Table>.SortedColumn returns the list of sorted columns.

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 through 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("ZM")
MemAdd("ZM", "abc", "abc")
MemAdd("ZM", "ZZZ", "ZZZ")
MemAdd("ZM", "zbc", "zbc")
MemAdd("ZM", "ééébc", "ééébc")
MemAdd("ZM", "AB", "AB")
MemAdd("ZM", "CD", "CD")
MemAdd("ZM", "çabc", "çabc")
MemAdd("ZM", "bbc", "bbc")
MemSort("ZM")
i is int
MemFirst("ZM")
WHILE NOT MemOut("ZM")
i = MemCurrent("ZM")
Trace(MemRetrieve("ZM", i)) // Affichage dans l'ordre ASCII
MemNext("ZM")
END
Component: wd270obj.dll
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment