|
|
|
|
- Overview
- Operating mode, programming and synchronization of a Table control based on a variable control
- Adding an element
- Modifying an element
- Deleting an element
- Handling a Table control based on a variable in a WLanguage code: stored value
- Changing through programming the base variable of a Table control based on a variable
- Limitation
Table control based on a variable
A Table control based on a variable is a Table control whose columns are bound to the elements of an Array variable, to the members of a class or to the elements of an advanced variable (e.g., xlsDocument). Each Table control column can be, for example: - Bound to a member of a class instance,
- Bound to an element in an array, etc.
- Calculated: A column that is not bound to a variable is a calculated column. For calculated columns, the content of the column is recalculated each time a row is displayed.
A Table control based on a variable allows you to: - View the content of an Array variable, the content of a class or the content of an advanced variable.
- Handle a table row (addition, deletion, modification, ...).
Caution: the Table control and the data source are not automatically synchronized. Depending on the action performed, changes must be propagated to the Table control or to the source. Operating mode, programming and synchronization of a Table control based on a variable control Adding an element - Case 1. Adding an element to the source of the Table control
To update a Table control with the new elements in its data source, use TableDisplay with the taInit constant. The selection and the sort performed by the user are lost. - Case 2. Adding an element to the Table control (cascading input)
To manage the cascading inputs, the additions must be performed through programming in the source. We advise you to:- Perform the additions one by one in the code used to exit from the row.
- Use TableDisplay (with the taInit constant) to update the bindings between the rows of the Table control and the elements in the source.
Modifying an element - Case 1. Changes in the source of the Table control
To propagate the changes from the source to the Table control, use TableDisplay. - Case 2. Changes in the Table control
If changes are made in the Table control, they are automatically reflected in the data source. If changes are made programmatically in the Table control (using WLanguage functions, for example), you need to call TableSave to confirm those changes. Then, changes are automatically reflected. Caution: Depending on the operations previously performed, changes may be propagated to a wrong location if the source and the Table control are not synchronized: the synchronization must always be maintained.
Deleting an element - Case 1. Deleting an item using its index in the source of the Table control
The element must be deleted manually from the Table control and from the source. TableSearch is used to find out the row of the Table control corresponding to the element (the stored value of the Table control must correspond to the element of the source). Limitation: For simple sources (e.g., array of integers), use TableDisplay with the taInit constant to update the bindings between the rows of the Table control and the elements in the source. The selection and the sort performed by the user are lost. - Case 2. Deleting an element using its index in the Table control
The element must be deleted manually from the Table control and from the source. TableSearch is used to find the index in the source that corresponds to the element deleted in the Table control. Limitation: For simple sources (e.g., array of integers), use TableDisplay with the taInit constant to update the bindings between the rows of the Table control and the elements in the source. The selection and the sort performed by the user are lost.
Handling a Table control based on a variable in a WLanguage code: stored value When handling a Table control based on a variable through programming: - using <Table control> in the code returns the content of the stored item.
- using <Table control> in a FOR EACH ROW loop returns the content of the stored item.
- using <Table control> [n] in the code returns the content of the stored item.
Changing through programming the base variable of a Table control based on a variable To change via programming the base variable of a Table control based on a variable control: - In the description window of the Table control, the type of filling for the Table control must be set to "by variable" ("Content" tab).
- By programming, define the value of the following properties for the Table control:
- BrowsedFile: this property is used to define the name of the data source for the fill. In this case, this property corresponds to an array of structures or to the name of an array of classes.
- StoredItem: this property corresponds to the value returned in memory by the Table control, when selecting a row.
- For each column in the Table control, use the DataBinding property to define the name of the member of the array variable that will fill the column.
- Display the data in the Table control with TableDisplay.
Code example:
// Declare the array STContact is Structure sLastName is string sFirstName is string sEmail is string END t_Contact is array of STContact // Assign the table properties TABLE_CONTACT.BrowsedFile = ":t_Contact" TABLE_CONTACT.StoredItem = ":t_Contact.sLastName" // Assign the properties of the table columns TABLE_CONTACT.COL_LASTNAME.DataBinding = ":t_Contact.sLastName" TABLE_CONTACT.COL_FIRSTNAME.DataBinding = ":t_Contact.sFirstName" TABLE_CONTACT.COL_EMAIL.DataBinding = ":t_Contact.sEmail" TableDisplay(TABLE_CONTACT)
The Table controls based on a simple type array (integers, character strings, ...) are available in read-only.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|