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
  • Overview
  • How to?
  • Adding a break into a Table control
  • Top and break footer
  • How to fill a Table control with breaks?
  • Manipulating the controls found in the break headers and footers
  • How to?
  • Example
  • Automatic calculations in the breaks of a Table control
  • Handling the break headers and footers
  • To initialize the break headers and footers
  • Properties associated with the break headers and footers
  • WLanguage functions specific to Table controls with breaks
  • Managing breaks in the Table controls programmatically
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
A break in a Table control is used to group rows according to one or more criteria.
For example, you have the ability to group:
  • the customers by country and by city,
  • the products according to their family, ...
WINDEV Implementing a total on a break is used to automatically perform a calculation (sum, count, average) for all the rows found in a given break. For example, a total on a break is used to calculate the turnover generated by each customer.
The breaks in a Table control are available for:
  • the Table controls based on a data file loaded in memory,
  • Table controls populated programmatically etc.
  • WEBDEV - Server codeWEBDEV - Browser codePHP the Table controls in Standard, AJAX and Browser mode.
WINDEV Remarks:
How to?

Adding a break into a Table control

To add a break into a Table control:
  1. Display the Table field description ("Description" option in the context menu).
  2. On the "Content" tab, click Icon for break addition. The window for break management is displayed.
    Note: Breaks are not available on Table fields based on a data file with direct access to the data source.
  3. Select the item on which the break must be performed. Several items can be selected in order to perform several breaks. The proposed items depend on the type of the Table control:
    • Table control based on a data file loaded in memory:
      • automatic browse: the browse item, the column linked to the browse item and the columns linked to no item are proposed. If the search item corresponds to a composite key, the components of this composite key, the columns linked to these components and the columns linked to no item are proposed.
      • programmed route: data file items and related columns are proposed.
    • Table control based on a data file linked to a query:
      • automatic browse: the browse item, the columns linked to this browse item and the columns linked to no item are proposed.. If the search item is not specified ("<Automatic>" option), the sorted items of the query, the columns linked to these items and the columns linked to no item are proposed.
      • programmed path: query items, columns linked to these items and columns linked to no item are proposed.
    • Table field by programming: all Table field columns are proposed.
  4. The breaks are performed according to their display order. Modify (if necessary) this order via the arrow buttons found on the right of table.
  5. Validate.

Top and break footer

When adding a new break, a break header and a break footer are automatically added to the Table control. If the Table control includes several breaks, there will be as many break headers and break footers as the number of breaks.
The break headers and the break footers appear in edit in the Table control.
The characteristics of these break headers and footers (name, visibility, background color, ...) can be modified in their description window ("Description" in the context menu).
Each break header and break footer is associated with the "Display a row" event. This event is executed when a new break header or break footer is displayed in the Table control.
These break headers and footers can contain controls. These controls can be handled programmatically. Various WLanguage events are associated with break headers.
WINDEV The sums, means and counts are automatically performed in the breaks of the Table control. The controls found in the break headers and footers can display these calculations. For more details, see Automatic calculations in the table breaks.
Remarks:
  • WINDEVAndroidiPhone/iPad In the description of the Table control ("Content" tab), you have the ability to specify whether the breaks must display (or not) a button used to collapse/expand the break ("Breaks with collapse/expand" option).
  • WEBDEV - Server codeWEBDEV - Browser codePHP In the description of the Table control ("Details" tab), if the type of fill is "Loaded in memory", the breaks can be collapsed/expanded via a simple click in the background of the break ("Collapsible/Expandable breaks via simple click in the background").
  • WINDEVAndroidiPhone/iPad In the description of the Table control, you have the ability to configure the image used to draw the "+" and "-" buttons in the table breaks. To do so, select the "Break, border in creation" element in the "Style" table then click the "Plus/Minus image of breaks" button.
  • WINDEVAndroidiPhone/iPad A break header can be always visible. In this case, during the scroll, the bar of the break will not be moved. In order for a break header to be always visible:
    • Select the break header and display its description ("Description" in the context menu).
    • On the "UI" tab, check "Break header always visible".

How to fill a Table control with breaks?

For the Table controls based on a data file, the addition of records is automatically performed according to the file or to the associated query. The sort is performed according to the search item.
For Table controls populated programmatically, data is added with TableAddLine. In order for a Table control to be sorted according to the specified breaks, you must use TableSort.
Example: Table field by programming: A break has been defined on the Country and City columns:
// Remplissage du champ Table
TableAddLine(TABLE_Ruptures, "FRANCE", "Montpellier", "TEXTE1", "Texte1")
TableAddLine(TABLE_Ruptures, "FRANCE", "Paris", "TEXTE2", "Texte2")
TableAddLine(TABLE_Ruptures, "FRANCE", "Montpellier", "TEXTE3", "Texte3")
TableAddLine(TABLE_Ruptures, "FRANCE", "Lille", "TEXTE4", "Texte4")

TableAddLine(TABLE_Ruptures, "ESPAGNE", "Madrid", "TEXTE1", "Texte1")
TableAddLine(TABLE_Ruptures, "ESPAGNE", "Barcelone", "TEXTE3", "Texte3")
TableAddLine(TABLE_Ruptures, "ESPAGNE", "Barcelone", "TEXTE4", "Texte4")

TableAddLine(TABLE_Ruptures, "ALGERIE", "Alger", "TEXTE5", "Texte5")
TableAddLine(TABLE_Ruptures, "ALGERIE", "Oran", "TEXTE6", "Texte6")
TableAddLine(TABLE_Ruptures, "ALGERIE", "Alger", "TEXTE7", "Texte7")
TableAddLine(TABLE_Ruptures, "ALGERIE", "Chlef", "TEXTE8", "Texte8")
TableAddLine(TABLE_Ruptures, "ALGERIE", "Alger", "TEXTE9", "Texte9")

TableAddLine(TABLE_Ruptures, "ESPAGNE", "Madrid", "TEXTE2", "Texte2")

// Tri du contenu du champ Table selon les ruptures
TableSort(TABLE_Ruptures, TABLE_Ruptures.Pays.Nom, TABLE_Ruptures.Ville.Nom)
Manipulating the controls found in the break headers and footers

How to?

To manipulate the controls found in the break headers and footers
  • handle each control found in all the break headers and footers:
    <Nom Champ>.<Nom Propriété> = <Valeur>
    ou
    <Nom Table>.<Nom Haut/Bas de rupture>.<Nom Champ>.<Nom Propriété> = <Valeur>
  • handle each control found in a given break:
    <Nom Table>[<Indice>].<Nom Champ>.<Nom Propriété> = <Valeur>

    <Subscript> corresponds to the row number for the break.
Remarks:
  • These lines of code must be in the "Display a row" event of the break header / footer.
  • Special case: Check Box control: a Check Box control with several options and located in the break footer cannot be programmatically assigned.. If several check boxes are required in the break headers and footers, we recommend that you use a Check Box control for each checkmark.

Example

This code is used to display in the "STC_Country" control the name of the country displayed in the Country column. This code is entered in the code for displaying a row of BreakHeader:
// Code d'affichage de la rupture
// Récupère l'indice de la rupture (ici RUPT_HautDeRupture) 
IndiceRupture is int = TableIndiceRupture(RUPT_HautDeRupture)

// Fixe la valeur du libellé contenu dans la rupture
TABLE_CLIENTS[IndiceRupture].LIB_PAYS = "Pays: " + TABLE_Articles.COL_NomPays
Automatic calculations in the breaks of a Table control
WINDEV
You have the ability to perform automatic calculations (sum, count and average) in the break headers and footers.
To implement the automatic calculations:
  1. Insert a Static Text control or an edit control into the break header and footer. This control will contain the automatic calculation.
  2. Open the control description window (select "Description" in the context menu).
  3. On the "UI" tab, in the "In a break, display" area, click the "No calculation" link or click the calculation description (if an automatic calculation was already defined). The description window of an automatic calculation is displayed.
  4. Select the calculation to perform. You can choose:
    • "The sum of": the field will display the sum per break.
    • "The average of": the field will display the average over the break.
    • "The number (count) of": the field will count the number of elements per break.
  5. Select the element on which the calculation must be performed. You have the ability to perform the calculation on a column of the Table control.
  6. Validate the different windows.
Tips:
  • Don't forget to modify the input mask of the control that displays the calculation according to the type of calculated information.
  • Don't hesitate to use the "eye magnet" technology on the edit controls that display calculations in the breaks. This gives you the ability you to highlight a calculation (displaying an insufficient turnover in red for example).
Handling the break headers and footers

To initialize the break headers and footers

All the break headers and footers can handled:
<Nom Haut/Bas de rupture>.<Nom Propriété> = <Valeur>
Remark: These lines of code must be present in the "Display line" event at the top/bottom of the break footer.
Example: Code used to modify the height of the breakpoints:
HautRupture1.Hauteur += 10

Properties associated with the break headers and footers

The following properties are associated with the break headers and footers:
CollapsedAllows you to find out and modify the "collapsed" status of a break.
HeightAllows you to find out and modify the height of a break header or footer.
WEBDEV - Server code Not available.
NameReturns the name of a break header or footer.
TypeReturns the type of an element.
VisibleAllows you to find out whether a break header or footer is visible and to make a break header or footer visible.

For a complete list of available properties, see Properties available for the breaks (Table).
WLanguage functions specific to Table controls with breaks
The following functions can be used to manipulate the breaks in the Table controls:
TableBreakIndexReturns the index of the break header and footer for a given break in a Table control.
TableCollapseCollapses:
  • a branch that was previously expanded in a TreeView Table control.
  • a break that was previously expanded in a Table control.
  • a detailed window displayed for a row.
TableCollapseAllCollapses:
  • the entire hierarchy (all nodes) of a TreeView Table control.
  • all breaks of a Table control.
TableExpandExpands:
  • a branch that was previously collapsed in a TreeView Table control.
  • a branch that was previously collapsed in a Table control.
  • a detailed window displayed for a row.
TableExpandAllExpands:
  • the entire hierarchy (all nodes) of a TreeView Table control.
  • all breaks of a Table control.
WINDEV
Managing breaks in the Table controls programmatically
The following functions are used to create and handle breaks in the tables:
BreakAddAdds a break into a Table or Looper control.
BreakDeleteDeletes a break from a Table control or from a Looper control.
BreakDeleteAllDeletes all breaks from a Table control or from a Looper control.
Adding a break into a table is performed by BreakAdd. The new break corresponds to a variable of type Control that can be handled with the same WLanguage properties as a break created in the editor.
Example:
// Ajout d'une rupture verte sur la date dans un champ Table
x is Control
x <- BreakAdd(TABLE_Commande.COL_DATE, "RuptDate", brkHeader, 50) 
x.CouleurFond = DarkGreen // Colorie en vert la rupture
Related Examples:
The Table control with break Unit examples (WINDEV): The Table control with break
[ + ] Using the Table control with break.
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help