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 / Table populated programmatically
  • Overview
  • Initializing a Table control populated programmatically
  • Adding rows to a Table control populated programmatically
  • Managing calculated columns
  • Modifying a row or column
  • Forcing the input
  • Adding or deleting a column
  • Operations on rows and cells
  • Deleting a row
  • Retrieving the content of a row or cell
  • Value of the cell in the current row
  • Value of a cell in a specific row
  • Content of the current row
  • Content of a specific row
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
Here is an overview of how to manipulate Table controls populated programmatically in WLanguage.
There are multiple WLanguage functions to handle this type of control. To learn more on these functions, see the documentation.
For more details, see Table control functions.
Initializing a Table control populated programmatically
Rows are not created automatically in a Table control. This must be specified by calling:
Note: if option "Cascading input (Add)" is not selected:
  • The Table control contains no rows when it is created:
    TABLE_MyTable.Count = 0.
    In this case, no input is allowed and Empty is set to True.
  • To automatically insert rows into a Table control, write the following lines of code in the control initialization event:
    IF TABLE_MaTable.Vide = True THEN TableAdd(TABLE_MaTable)
Adding rows to a Table control populated programmatically
You can add rows to a Table control:
WINDEVWEBDEV - Server codeJavaPHP If a new row was added to the Table control with TableAdd, TableInsert, TableAddLine or TableInsertLine, New is set to True (otherwise, it is set to False).
Managing calculated columns
The calculation formula of a calculated column must be defined in the "Display a row" event of a Table control. For example:
// COL_PHT: colonne calculée
// COL_PUHT et COL_QTE: colonnes remplies par programmation
COL_PHT = COL_PUHT * COL_QTE
Modifying a row or column
The content of the rows and columns in a Table control can be modified:
  • by the user, by entering data directly in the columns. The changes are automatically saved in the Table control (no additional code is required). The Modified property is set to True.
  • programmatically:
    • with TableModify to change the content of the current row or the content of a given row.
      For example:
      TableModify(TABLE_CLIENT, "PY" + TAB + "Jean" + TAB + "Nîmes")

      Note: it is also possible to use the Table field name directly:
      // Modifier la ligne en cours
      TABLE_CLIENT = "DURAND" + TAB +"Sophie" + TAB + "Nîmes"
      // Modifier la ligne 3
      TableModify(TABLE_JOUR, "Mercredi" + TAB + "Vaqué", 3)
    • by specifying the name of the column to change the content (as for an Edit control). To modify the column of a specific row, the row number must be specified (index).
      For example:
      COL_NOM[Indice] = SAI_NomClient

      To modify the column of the current row, there is no need to specify the index. For example:
      COL_NOM = SAI_NomClient

      The Modified property is set to False (it is set to True only when data is entered in the Table control).
WINDEVWindowsJavaUser code (UMC)

Forcing the input

SetFocusAndReturnToUserInput can be used to resume input in a column, on the current row.
For example:
// Traitement d'entrée colonne COL_QTE
// COL_QTE ne peut pas être saisi, 
// si COL_PRODUIT n'est pas saisi
IF NoSpace(COL_PRODUIT) = "" THEN
	Error("La colonne Produit doit être saisie en premier")
	SetFocusAndReturnToUserInput(COL_PRODUIT)
END
WINDEVWEBDEV - Server codeWindowsJavaUser code (UMC)

Adding or deleting a column

You can:
  • Add a column to a Table control populated programmatically with ControlClone.
  • Delete a column from a Table control populated programmatically with ControlDelete.
Operations on rows and cells

Deleting a row

You can delete rows by calling TableDelete. The syntax used is as follows:
TableSupprime(<Champ Table>[, <Indice>])
If the index is specified, TableDelete deletes the row that corresponds to that index. Otherwise, the current row is deleted. For example:
TableDelete(TABLE_CLIENT)
Deleting a row from a Table control also deletes all the values of the columns for that row.
A row can be selected with TableSelectPlus.
The syntax used is as follows:
TableSelectPlus(<Champ Table>[, <Indice>])

Retrieving the content of a row or cell

The content of a Table control populated programmatically can be retrieved:
  • for the entire row.
  • cell by cell.

Value of the cell in the current row

To retrieve the value of a column (or cell) for the current row, the syntax is the same as for a simple Edit control.
<Valeur> = <Nom Colonne>
Example:
// COL_QTE est une colonne du champ Table
IF COL_QTE < 10 THEN
	Info("Qté insuffisante")
END

Value of a cell in a specific row

To retrieve the value of a column that is not in the current row, you must specify the index of the row.
<Valeur> = <Nom Colonne>[<Indice>]
For example:
// Totaliser le Prix PHT pour toutes les lignes de commande
PrixTotal = 0
FOR Indice = 1 _TO_ TABLE_COMMANDE.Occurrence
	PrixTotal = PrixTotal + COL_PHT[Indice]
END

Content of the current row

To retrieve the content of the current row, use the following syntax:
<Valeur> = <Champ Table>

Content of a specific row

To get the content of the row at index <Index>, use the following syntax:
<Valeur> = <Champ Table>[<Indice>]

Remark: The current line index can be known by the TableSelect function..
For example:
// Récupérer la ligne 10 dans le champ Table TABLE_CLIENT
LigneEnCours = TABLE_CLIENT[10]
 
// Nom du client sélectionné
NomClient = COL_NOM[TableSelect(TABLE_CLIENT)]
 
// Récupérer la ligne en cours dans le champ Table TABLE_CLIENT
LigneEnCours = TABLE_CLIENT
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help