ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
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:
TableAddLine(<Name of Looper control>[Row index].<Name of Table control>,
<Element Column 1>, <Element Column 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:
PROCÉDURE FillOrdersOfTheDay()

// Local variables
nIndex is int

// Clears the Looper control
LooperDeleteAll(LOOP_OrdersOfTheDay)

// Browse the orders of the day
FOR EACH Order WITH "OrderDate = '"+Today() + "' AND IsFinalized = 0"

// Finds the associated contact
HReadSeekFirst(CustomerContact, CustomerContactID, Order.CustomerContactID)
IF HFound(CustomerContact) = False THEN CONTINUE

// Adds a row into the Looper control
nIndex = LooperAddLine(LOOP_OrdersOfTheDay, Order.OrderID, ...
CustomerContact.Company, CustomerContact.LastName + ...
[" "] + CustomerContact.FirstName)

// Browses the order lines
FOR EACH OrdLine WITH OrderID = Order.OrderID
HReadSeekFirst(Product, ProductID, OrdLine.ProductID)
IF HFound(Product) = False THEN CONTINUE

// Add the ordered elements into the Table control
TableAddLine(LOOP_OrdersOfTheDay[nIndex].TABLE_Order, ...
Product.ProductID, Product.Caption, OrdLine.Quantity)
END
END
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:
TableAddLine(<Name of Table control>, <Element column 1>, <Element column 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:
TreeAdd(<Name of Looper control>[Row index].
<Name of Internal Window>.<Name of TreeView Control>, <Element to Add>)
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 10/02/2023

Send a report | Local help