ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Table control / Data-bound Table
  • Overview
  • Select
  • Deleting a line in a Table control linked to a data file
  • Managing calculated columns
  • Retrieving the content of a row, column or cell
  • Important
  • Value of the cell in the current row
  • Value of a cell in a specific row
  • Content of the current row
  • Content of row X
  • Content of the selected rows for a multiple selection
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
Here are the main points for programming Table fields linked to a data file. WLanguage provides a number of functions for programmatically managing Table controls linked to a data file.
To learn more on these functions, see the documentation. For more details, see List of functions specific to Table controls.
Select
A row can be selected with TableSelectPlus.
If no stored item is defined for the Table control, you also have the ability to use the following syntax:
<Table control> = <Number of row to select>
Adding and modifying a line in the Table control (and a record in the data file) is a two-stage process:
  1. Add or modify the record in data the file (via a form window or page, for example).
  2. Table control redisplay:
    • WINDEVAndroidiPhone/iPad refreshing the Table control.
    • WEBDEV - Server code refresh the page.
Deleting a line in a Table control linked to a data file
To delete a line in the Table control linked to a data file, use the TableDelete function. TableDelete deletes the corresponding record from the data file.
WEBDEV - Server code In WEBDEV, the page must be redisplayed.
Important To delete a record in the data file, do not use the HDelete function, otherwise data in the data file will be lost.
Managing calculated columns
The calculation formula of a calculated column must be defined in the "Display a row" event of a Table control.
Example of code in the "Display a row" event of the Table control:
// COL_MsgAlerte : une colonne calculée 
// La colonne COL_MsgAlerte affiche "Alerte" si COL_Stock<200
IF COL_Stock < 200 THEN
	COL_MsgAlerte = "Alerte"
ELSE
	COL_MsgAlerte = ""
END

By definition, a Calculated control is not linked to a field: the value assigned by a line's display code is not memorized after dequeueing the Table control lines via the vertical scrollbar.
For example, the "FOR ALL ROWS" instruction will not assign or retrieve the value of a calculated column from all Table control rows.
If the Table control is a Table control linked to a data file but "Loaded in memory" (option "Loaded in memory" checked in the "Contents" tab of the control description window), the calculated columns will be memorized when the Table control is run.
Retrieving the content of a row, column or cell

Important

The contents of a line in a Table control linked to a data file can be retrieved:
  • by retrieving the entire row.
  • cell by cell.

Value of the cell in the current row

The cell is identified by the name of the column. The following syntax must be used:
<Value> = <Column name>
Example:
// COL_QTE est une colonne du champ Table
IF COL_QTE < 10 THEN
	Info("Quantité insuffisante")
END

Value of a cell in a specific row

The cell is identified by the name of the column. The following syntax must be used:
<Value> = <Column name>[<Row index>]
Example:
// Totalise le Prix présent dans la colonne COL_PHT 
// pour toutes les lignes de commande affichées
PrixTotal = 0
FOR Indice = 1 TO TABLE_COMMANDE.Occurrence
	PrixTotal = PrixTotal + COL_PHT[Indice]
END

Content of the current row

The following syntax must be used:
<Value> = <Table control>
You also have the ability to use the following syntax:
<Value> = <Table control>[<Table control>]

Content of row X

The following syntax must be used:
<Value>=<Table control>[<Row index>]
Remark: The line index can be given by the TableSelect function..
// Récupère la ligne en cours du champ TABLE_CLIENT
LigneEnCours = TABLE_CLIENT

// Nom du client sélectionné
NomCli = COL_NOM[TableSelect(TABLE_CLIENT)]

Content of the selected rows for a multiple selection

The following syntax must be used:
<Value>=<Table control>[<Row index>]
Remark: To find out the indices of the selected lines, use functions TableSelectCount and TableSelect..
// Trace le contenu des lignes sélectionnées
i is int
NbSelectionne is int = TableSelectCount(TABLE_Produit) 
FOR i = 1 TO NbSelectionne 
	Trace("Ligne sélectionnée : " + ...
			TABLE_Produit[TableSelect(TABLE_Produit, i)]) 
END 

// Equivalent à :
// POUR TOUTE LIGNE SELECTIONNEE DE TABLE_Produit
//	Trace("Ligne sélectionnée : " + TABLE_Produit[TableSelect(TABLE_Produit, i)])
// FIN

Note The Table control fields are not available:
  • If the Table control contains proportional scrollbars.
  • If the Table control is "5.5 compatible".
  • In Table controls displayed by Combo Boxes.
Note The Multiselection property indicates the selection mode of a Table control.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/05/2025

Send a report | Local help