AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Controles, páginas y ventanas / Funciones Tabla
  • Use conditions
  • Sorting a Table or TreeView Table control based on a data file
  • Managing a sorted Table or TreeView Table control
  • Sort on a calculated column
  • Programmatically loop through Table or TreeView Table controls
  • Performing a sort according to the ASCII value
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Sorts a Table or TreeView Table control on one or more columns (lexicographical sort).
Note: When a field is sorted using the TableSortfunction, the images used to identify the sorting direction are not displayed in the columns..
Ejemplo
// Sort "COL_Designation" and "COL_Price" columns in "TABLE_Product"
// "COL_Designation" is sorted in ascending order
// "COL_Price" is sorted in descending order
TableSort(TABLE_Product, "COL_Designation", "-COL_Price")
// Multicolumn sort of Table control
// "COL_Designation" is sorted in descending order
// "COL_Price" is sorted in ascending order 
TableSort("-COL_Designation" + TAB + "+COL_Price")
Sintaxis

Sorting a Table or TreeView Table control on one or more columns identified by their name Ocultar los detalles

<Result> = TableSort(<Table control> , <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.
If this parameter corresponds to an empty string (""), the control to which the current event belongs will be used.
<Column 1>: Character string
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 sorting (default),
    • "-": sorting in descending order.
  • <Nom de la colonne> (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:
"[<Direction>]<Column name>"

where:
  • <Direction> (character) indicates the sort direction:
    • "+": ascending sorting (default),
    • "-": sorting in descending order.
  • <Nom de la colonne> (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:
"[<Direction>]<Column name>"

where:
  • <Direction> (character) indicates the sort direction:
    • "+": ascending sorting (default),
    • "-": sorting in descending order.
  • <Nom de la colonne> (string): name of column to sort.

Sorting a Table or TreeView Table control according to a list of column names Ocultar los detalles

<Result> = TableSort(<List of columns>)
<Result>: Boolean
  • True if the sort was performed,
  • False otherwise.
<List of columns>: Character string
List of columns to sort (up to 16 columns). This parameter has the following format:
"[<Direction>]<Column1>" + TAB + "[<Direction>]<Column2>" + TAB + ...

where:
  • <Direction> (character) indicates the sort direction:
    • "+": ascending sorting (default),
    • "-": sorting in descending order.
  • <Colonne> (string): name of the column to be sorted. The name of a column is returned by TableEnumColumn. If two controls have identical column names, the name of the column must be used as prefix in the name of the control (e.g.: "+TABLE_Table1.COL_SortColumn"+TAB+"TABLE_Table1.COL_PriceColumn").

Sorting a Table or TreeView Table control on the first ten visible columns of the control Ocultar los detalles

<Result> = TableSort(<Table control> [, <To sort>])
<Result>: Boolean
  • True if the sort on the first 10 control columns 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.
This parameter has the following format:
"[<Direction>]<Name of Table control>"

where:
  • <Direction> (character) indicates the sort direction:
    • "+": ascending sorting (default),
    • "-": sorting in descending order.
  • <Nom du champ Table> (string): name of the Table or hierarchical Table field whose first 10 columns are to be sorted.
<To sort>: Optional boolean
  • True if the sort on the first 10 control columns must be performed,
  • False if the previous sort must be canceled. Once the sort is canceled, the order of the rows is not modified but the rows that will be added by TableAdd, TableAddLine, TableInsert or TableInsertLine will not be sorted.

Canceling a sort that was previously defined on a Table or TreeView Table control populated programmatically Ocultar los detalles

<Result> = TableSort(<Table control> , <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 Table control populated programmatically.
  • a TreeView Table control populated programmatically.
<False>: Constant
False: Keyword used to cancel a sort previously programmatically defined on a Table or hierarchical Table field.
Observaciones

Use conditions

TableSort can be used on:
  • Table or TreeView Table controls populated programmatically.
  • a Table or TreeView Table control based on a data file with automatic iteration ("Browse automatically" option in the "Content" tab of the control description). In this case, only one column is sorted.
  • single-selection or multi-selection controls.
    WEBDEV - Código ServidorPHP Reminder Multi-selection is not available for Table control fields in classic mode.
WEBDEV - Código ServidorPHP This function is available for Table controls in "Server" and "Server + AJAX" mode, and for TreeView Table controls.
WEBDEV - Código Navegador This function is available for Table controls in "Browser" mode only.
WEBDEV - Código Navegador The TreeView Table control is not available.

Sorting a Table or TreeView Table control based on a data file

A Table or TreeView Table control based on a data file will be sorted according to the first specified column (syntax 1 and 2). Warning: the column used for sorting must be linked to a key item in the data file used to browse the field.
Tip To sort a Table or TreeView Table control file with multiple columns, use a compound key and the BrowsedItem property:
TableName..BrowsedItem = NAMECOMPOSITEKEY
To cancel a sort in a Table or TreeView Table control based on a data file, simply assign an empty string to the BrowsedItem property.

Managing a sorted Table or TreeView Table control

Reminder: The TableSortedColumn function is used to obtain a list of sorted columns.

Sort on a calculated column

It is not recommended to use TableSort on calculated columns. These columns are calculated when each row is displayed.
A sort defined with TableSort on a calculated column will be valid only for the rows already displayed.

Programmatically loop through Table or TreeView Table controls

TableSort has no effect on controls looped through programmatically.

Performing a sort according to the ASCII value

A memory area 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
Componente: wd300obj.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
exemplo tablesort
https://windevdesenvolvimento.blogspot.com/2021/05/dicas-3321-windev-webdev-mobile.html

https://youtu.be/zjnXniNTWwU

SWITCH COMBO_ordem
CASE 1
IF CBOX_ordem_inversa=True THEN
TableSort(TABLE_cliente_consulta,"-TABLE_cliente_consulta.COL_Cliente_wdID")
ELSE
TableSort(TABLE_cliente_consulta,"TABLE_cliente_consulta.COL_Cliente_wdID")
END

CASE 2
IF CBOX_ordem_inversa=True THEN
TableSort(TABLE_cliente_consulta,"-TABLE_cliente_consulta.COL_nome")
ELSE
TableSort(TABLE_cliente_consulta,"TABLE_cliente_consulta.COL_nome")
END

CASE 3
IF CBOX_ordem_inversa=True THEN
TableSort(TABLE_cliente_consulta,"-TABLE_cliente_consulta.COL_email")
ELSE
TableSort(TABLE_cliente_consulta,"TABLE_cliente_consulta.COL_email")
END
OTHER CASE

END
amarildo
05 05 2021

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local