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 based on a variable
  • Overview
  • Operating mode, programming and synchronization of a Table control based on a variable
  • Adding an element
  • Modifying an element
  • Deleting an element
  • Table control based on a variable in WLanguage code: stored value
  • Changing the base variable of a Table control programmatically
  • Limitation
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
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).
For example, each Table control column can be:
  • Bound to a member of a class instance,
  • Bound to an element in an array, etc.
  • Calculated: If the column is not linked to a variable, it is an 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, class or advanced variable.
  • Handle a table row (add, delete, modify, etc.).
Warning: synchronization between the Table field and its source is not automatic.. 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

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 selections and sorts performed by the user will be lost.
  • Case 2. Adding an element to the Table control (cascading input)
    To manage cascading inputs, new elements must be added to the data source programmatically.
    We advise you to:
    • Add elements 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 data source.

Modifying an element

  • Case 1. Changes in the data source of the Table control
    To update the Table control with the changes from the data source, 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 carried out previously, it is possible that the transfer is made in the wrong place if the source and the Table field are not in phase: it is necessary to maintain synchronization at all times.

Deleting an element

  • Case 1. Deleting an element using its index in the data source of the Table control
    The element must be deleted manually from the Table control and from the data source.
    TableSearch returns the row of the Table control that corresponds to the element (the value in the Table control must correspond to the element in the data source).
    Limitation: For simple source types (e.g. integer arrays), use function TableDisplay with constant taInit to update "links" between Table field rows and source elements.. The selections and sorts performed by the user will be 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 data source.
    TableSearch returns the index in the data source that corresponds to the element deleted in the Table control.
    Limitation: For simple source types (e.g. integer arrays), use function TableDisplay with constant taInit to update "links" between Table field rows and source elements.. The selections and sorts performed by the user will be lost.
Table control based on a variable in WLanguage code: stored value
When manipulating 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 the base variable of a Table control programmatically
To programmatically change the base variable of a Table control:
  1. In the description window of the Table control, select the population mode "From a variable" ("Content" tab).
  2. In the code, define the value of the following properties for the Table control:
    • BrowsedFile: this property defines the data source. 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 in-memory value returned by the Table control when a row is selected.
  3. For each column in the Table control, use the DataBinding property to define the member of the array variable that will populate the column.
  4. Display the data in the Table control with TableDisplay.
Code sample:
// Déclaration du tableau
STContact is Structure
	sNom is string
	sPrénom is string
	sEmail is string
END

t_Contact is array of STContact


// Affectation des propriétés de la table
TABLE_CONTACT.FichierParcouru = ":t_Contact"
TABLE_CONTACT.RubriqueMémorisée = ":t_Contact.sNom"

// Affectation des propriétés des colonnes de la table
TABLE_CONTACT.COL_NOM.LiaisonFichier = ":t_Contact.sNom"
TABLE_CONTACT.COL_PRENOM.LiaisonFichier = ":t_Contact.sPrénom"
TABLE_CONTACT.COL_EMAIL.LiaisonFichier = ":t_Contact.sEmail"

TableDisplay(TABLE_CONTACT)
Limitation
Table controls based on an array of simple types (integers, strings, etc.) are available in read-only mode.
Minimum version required
  • Version 14
This page is also available for…
Comments
  Can select the columns, which will not be exported
 Hoje Minha dica
é como colocar ou eliminar
Lupa nas colunas
Movimentar ou não as colunas
Tambem vou Mostrar Novidade No WinDev22
Poder selecionar as colunas, que não serão exportadas
//====================
My tip today
Is how to put or remove
Magnifying glass on the columns
Move or not the columns
I'll also Show What's New In WinDev22
Can select the columns, which will not be exported
//====================
Aujourd'hui Mon conseil
est comme mettre ou éliminer
Lupa dans les colonnes
Déplacer ou non les colonnes
Aussi montrera Nouveautés WinDev22
Vous pouvez sélectionner les colonnes qui ne seront pas exportés
//====================
http://windevdesenvolvimento.blogspot.com.br/2017/02/aula-1076-windev-tabela-048-bloquear-ou.html

https://www.youtube.com/watch?v=7S5k-jHUn9Y

De matos
10 Mar. 2017

Last update: 09/21/2024

Send a report | Local help