ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Controls, pages and windows / Table functions
  • Use conditions
  • Row characteristics
  • Position of the new row
  • Limits: Maximum number of lines displayed
  • Miscellaneous
  • Adding rows
  • Cascading input
  • Table field/Hierarchical file table: Changes to the linked data file
  • Table field/Hierarchical table file: Add several lines
  • Adding a record to a Table control based on a data file and releasing a trigger
  • Table or TreeView Table control based on a data file in edit mode
  • Adding images
  • Unicode management
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Adds a row in:
  • a Table control,
  • a TreeView Table control,
  • WINDEV a Combo Box control "with table" (Table control displayed in a Combo Box control).
Note: We recommend using the TableAddLine function.. TableAddLine is used to add:
  • TAB characters into the columns,
  • all types of values into the columns,
  • UNICODE data automatically and without conversion.
Example
// Ajout de "Dubois", "Pierre" et "21/06/72"
// à la fin du champ "TABLE_TableClient"
ResAjout = TableAdd(TABLE_TableClient, "Dubois" + TAB + "Pierre" + TAB + "21/06/72")
Syntax
<Result> = TableAdd(<Table control> [, <Row>])
<Result>: Boolean
  • True if the element was added,
  • 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.
  • WINDEV a Combo Box control with table.
If this parameter corresponds to an empty string (""), the control to which the current event belongs will be used.
<Row>: Optional character string
Row to add. This row has the following format:
<Elément de la colonne 1> + TAB + <Elément de la colonne 2> + TAB + ...

If this parameter is not specified, an empty row is added into the control. For a control based on a data file, the default values defined in the linked data file are taken into account.
Remarks

Use conditions

TableAdd can be used on:
  • Table or TreeView Table controls based on a data file.
  • Table or TreeView Table controls populated programmatically.
  • single-selection or multi-selection controls.
    WEBDEV - Server codePHP Reminder: Multi-selection is not available for Table fields in "Server" mode.
WEBDEV - Server codePHP This function is available for Table controls in "Server" and "Server + AJAX" mode, and for TreeView Table controls.
WEBDEV - Browser code This function is available for Table controls in "Browser" mode only.
WEBDEV - Browser code The TreeView Table control is not available.
AndroidiPhone/iPad Table controls based on a data file are not available in edit mode. TableAdd cannot be used on Table controls based on a data file.

Row characteristics

  • Each added element is converted into the type of the relevant column.
  • To specify no value for an element, use an empty string ("") or 0 (according to the type of column). For example:
    TableAdd(TABLE_TableClient, "Dubois" + TAB + "Pierre" + TAB + "" + TAB + "21/06/72")
  • If an element corresponds to the calculation result, the numeric expression must be enclosed in brackets. For example:
    TableAdd(TABLE_TableCalcul, (53+29) + TAB + (83-21))

Position of the new row

By default, the row is added at the end of the rows displayed by the control.
Special case:
  • If the control is sorted by TableSort, the added row is positioned in the control according to the current sort.
  • If the control is sorted by the user, the sort is ignored when inserting the row. The row is added at the end of control.

Limits: Maximum number of lines displayed

The maximum number of rows that can be displayed in a TreeView Table control or Hierarchical Table is limited only by available RAM (theoretical maximum: 2 billion rows).
However, we do not advise you to use large Table or TreeView Table controls for performance and user-friendliness reasons (time required to fill the control for example).

Miscellaneous

  • To add a row at a specific position in a Table or TreeView Table control, use TableInsertLine.
  • If the added row is the first row of the control, the added row becomes the current row.
WINDEVWEBDEV - Server codeJavaPHP

Adding rows

The NewLine property is used to determine if the current row has just been created by TableAdd (NewLine = True).
WINDEVWEBDEV - Server codeJavaPHP

Cascading input

To perform a cascading input, TableAdd must be used in the "Exit a row" event of the Table control:
IF TABLE_TableClient.Nouveau THEN
	TableAdd(TABLE_TableClient)
END
WEBDEV - Server codePHP This function is only available for Table fields in Ajax mode..
WINDEVWEBDEV - Server codeJavaPHP

Table field/Hierarchical file table: Changes to the linked data file

  • If the cascading input is enabled, the data file linked to the control is automatically modified when the user goes to the next row.
  • If the cascading input is not enabled, the data file linked to the control is not modified. To write the content of the new row to the linked data file, TableSave must be used after TableAdd.
Remarks:
  • The "Cascading input (Add)" option can be selected in the "Details" tab of the control description.
  • Java The cascading input is not available for Table controls with direct access to the data source. This option is only available for Table controls populated programmatically and with in-memory data source.
  • WEBDEV - Server code Cascading input is only available for "Server + AJAX" Table controls based on a data file.
WINDEVWEBDEV - Server codeJavaPHP

Table field/Hierarchical table file: Add several lines

A virtual row is created each time TableAdd is called in a Table or TreeView Table control based on a data file. The information will be saved in the linked data file only when TableSave is called.
If TableAdd is successively called in the same process without being followed by TableSave, only the FIRST call is effective (the following calls are ignored). Only one row is added to the Table or TreeView Table control.
WEBDEV - Server codePHP This operating mode is only available for "Server + AJAX" Table controls based on a data file.
WINDEVWEBDEV - Server codeJavaUser code (UMC)

Adding a record to a Table control based on a data file and releasing a trigger

A trigger can be released when a record is added in a Table control based on a data file. For more details, see the documentation about HDescribeTrigger.
WEBDEV - Server code This operating mode is only available for "Server + AJAX" Table controls based on a data file.
WINDEVJavaUser code (UMC)

Table or TreeView Table control based on a data file in edit mode

If TableAdd is called:
  • In a control event, the cursor is automatically positioned on the first editable column in the new row.
  • In an event that does not belong to the control (or in another process), SetFocusAndReturnToUserInput must be used to resume the input in the Table or TreeView Table control.

Adding images

To add an image to a Table or TreeView Table control:
  • WINDEV specify the name and full path of the image to be added.
    For example:
    TableAdd(TABLE_MaTable, "C:\MesDocuments\MonImage.BMP")
  • WEBDEV - Server codePHP specify the path and name of image to add. The path is relative to the "<Project_Name>_WEB" directory.
    For example:
    // Ajoute l'image située dans le répertoire "WB_MonAppli_WEB"
    TableAdd(TABLE_MaTable, "MonImage.BMP")
Note: To display the added image correctly, the column must be of type Image.

Unicode management

You can define how Unicode will be managed in the project configuration ("Unicode" tab of the configuration description window):
  • If "Use ANSI strings at runtime" is selected: data is converted using the current character set.
    Reminder: ChangeCharset is used to modify the current character set.
  • If "Use UNICODE strings at runtime" is selected, the data is inserted without being converted.
Component: wd300obj.dll
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