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 / Looper control
  • Overview
  • How to?
  • Including a Table control in a Looper control
  • Including a control in a Looper control
  • Accessing the contents of internal window fields from the host window
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
In a Looper control, a different content can be assigned to the Table, Chart, List Box and TreeView controls:
  • If the control to repeat is a Table control or a Chart control, all you have to do is insert it into the Looper control directly.
  • If the control to repeat is another type of control (List Box control, TreeView control, etc.), simply insert this control into an internal window. Then, all you have to do is create the associated Internal Window control in the Looper control.
Remark: The Table and Chart controls or the controls in the internal window must be populated programmatically.
How to?

Including a Table control in a Looper control

To include a Table control in a Looper control:
  1. If necessary, create a Looper control: based on a data file, based on a variable, or populated programmatically.
  2. Insert the Table control into the Looper control. The Table control must be populated programmatically.
  3. Make sure that "Identical content for all the rows" is unchecked ("UI" tab in the description window of the Table control).
  4. The Table control can now be populated programmatically.
The Table control found in the Looper control can be filled by using TableAddLine according to the following method:
TableAjouteLigne(<Nom du champ Zone répétée>[Indice de la répétition].<Nom du champ Table>,
<Elément colonne 1>, <Elément colonne 2>, ...)
Example: The following code is used to populate the content of the Table control found in the Looper control. The Looper control lists the orders and the Table control lists the products ordered.
The following code is used to fill both the Looper control and the Table control:
PROCEDURE RemplirCommandesDuJour()

// Variables locales
nIndice is int

// Vide le champ Zone répétée
LooperDeleteAll(ZR_CommandesDuJour)

// Parcours des commandes du jour
FOR EACH Commande where "DateCommande = '" + Today() + "' AND EstFinalisée = 0"

	// Recherche le contact associé
	HReadSeekFirst(ContactClient, IDContactClient, Commande.IDContactClient)
	IF HFound(ContactClient) = False THEN CONTINUE

	// Ajoute une ligne dans le champ Zone répétée
	nIndice = LooperAddLine(ZR_CommandesDuJour, Commande.IDCommande, ...
			ContactClient.Societe, ContactClient.Nom + ...
			[" "] + ContactClient.Prénom)

	// Parcours les lignes de commandes
	FOR EACH LigneCde where IDCommande = Commande.IDCommande
		HReadSeekFirst(Produit, IDProduit, LigneCde.IDProduit)
		IF HFound(Produit) = False THEN CONTINUE

		// Ajout des éléments commandés dans le champ Table
		TableAddLine(ZR_CommandesDuJour[nIndice].TABLE_Commande, ...
			Produit.IDProduit, Produit.Libellé, LigneCde.Quantité)
	ENDEND
To get an easier syntax, the fill operation can be directly performed in the code for displaying a row of Looper control. In this case, there is no need to specify the index of the main looper. The syntax becomes:
TableAjouteLigne(<Nom du champ Table>, <Elément colonne 1>, <Elément colonne 2>, ...)
Tip: Don't forget to clear the Table control in the display code of a row of the Looper control, before it is populated by TableDeleteAll.

Including a control in a Looper control

To integrate another control (List Box, TreeView, etc.) into the Looper control:
  1. If necessary, create a Looper control: based on a data file, based on a variable, or populated programmatically.
  2. Insert an Internal Window control into the Looper control.
  3. Make sure that "Identical content for all the rows" is unchecked ("UI" tab in the description of the Internal Window control).
  4. Create an internal window if necessary. Insert the control (Chart, List Box, TreeView, etc.) into this internal window. The inserted control must be populated programmatically.
  5. Associate the Internal Window control with the internal window ("General" tab in the description of Internal Window control).
  6. The control can now be populated programmatically.
For example, TreeAdd can be used as follows in order to fill a TreeView control found in a Looper control:
ArbreAjoute(<Nom du champ Zone répétée>[Indice de la répétition].
<Nom de la fenêtre interne>.<Nom du champ Arbre>, <Elément à ajouter>)

Accessing the contents of internal window fields from the host window

To access the contents of the control s of the internal window from the host window, simply handle the desired repetition, the internal window and then the control.
Example: Retrieve the value of an edit control of type date from the first occurrence of Looper control:
x est Champ <- ZR_SansNom1[1]
Trace(x.FI_SansNom1.SAI_DATE)
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 03/14/2024

Send a report | Local help