|
|
|
|
|
- Overview
- Selecting, adding and modifying a row in a Table control based on a data file
- Deleting a row from a Table control based on 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
Programming Table controls based on a data file (prefix syntax)
This page explains how to program Table controls based on a data file. There are multiple WLanguage functions to programmatically handle this type of Table controls. Selecting, adding and modifying a row in a Table control based on a data file A row can be selected with <Table>.SelectPlus. If no stored item is defined for the Table control, you can use the following syntax: <Table control> = <Number of row to select> To add and modify rows in the Table control (or records in the data file), follow these two steps: - Add or modify the record in data the file (via a form window or page, for example).
- Display the Table control again:
- refresh the Table control.
Deleting a row from a Table control based on a data file To delete a row from the Table control based on a data file, use <Table>.Delete. <Table>.Delete deletes the corresponding record from the data file.
Important: To delete a record from the data file, do not use <Source>.Delete, otherwise you may lose data. Managing calculated columns The calculation formula of a calculated column must be described in the "Display a row" event of a Table control. Example of code in the "Display a row" event of the Table control: // COL_AlertMsg: a calculated column // The COL_AlertMsg column displays "Alert" if COL_Stock<200 IF COL_Stock < 200 THEN COL_AlertMsg = "Alert" ELSE COL_AlertMsg = "" END
By default, a calculated column is not bound to an item: the value assigned in the display code of a row is lost after scrolling vertically through the rows in a Table control. For example, a "FOR EACH LINE" statement cannot be used to assign or retrieve the value of a calculated column for all the rows of the Table control. If the Table control uses an in-memory data source ("Loaded in memory" option checked in the "Content" tab of the control description window), the value in the calculated columns will not be lost at runtime. Retrieving the content of a row, column or cell Important The content of a row in a Table control based on 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: Example: // COL_QTY is a column of the Table control IF COL_QTY < 10 THEN Info("Insufficient quantity") 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: // Adds the price found in the COL_PBT column  // for all the order lines displayed TotalPrice = 0 FOR Index = 1 TO TABLE_ORDER.Count TotalPrice = TotalPrice + COL_PBT[Index] END
Content of the current row The following syntax must be used: <Value> = <Table control> You can also 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 index of the row is returned by <Table>.Select.
// Retrieves the current row in TABLE_CUSTOMER CurrentRow = TABLE_CUSTOMER Â // Name of the selected customer CustName = COL_NAME[TABLE_CUSTOMER.Select()]
Content of the selected rows for a multiple selection The following syntax must be used: <Value>=<Table control>[<Row index>] Remark: To get the indices of the selected rows, you must use <Table>.SelectCount and <Table>.Select.
// Traces the content of the selected rows i is int NbSelected is int = TABLE_Product.SelectCount() FOR i = 1 TO NbSelected Trace("Selected row: " + ... TABLE_Product[TABLE_Product.Select(i)]) END Â // Equivalent to: // FOR EACH SELECTED ROW OF TABLE_Product // Trace("Selected row: " + ... // TABLE_Product[Product.Select(i)]) // END
Remark: Multi-selection Table controls based on a data file 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.
Remark: The Multiselection property allows you to get the selection mode of a Table control.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|