ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Programming
  • Method 1: Table controls linked by the Filter property
  • Creating the first Table control
  • Creating the second Table control
  • Establishing the link between the Table controls
  • Using queries
  • Creating the query
  • Creating the second Table control
  • Establishing the link between the Table controls
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
We name cascading Tables two Table controls whose content is linked. For example:
  • Display families of products in a Table control.
  • For each family selected in the Table control, display the products that belong to it in a second Table control.
This help page explains how to create cascading Tables:
Method 1: Table controls linked by the Filter property
When the Filter property is used on a Table control, it allows you to filter the content of the control based on a value. This value is checked in relation to the search item defined for the Table control. The filter is applied to the second Table control. The row selection code enables the filter.
In this example, the customers of the CUSTOMER data file will be displayed in the main Table control. The second Table control will contain the orders of the customer selected in the first Table control.
The steps for creating these 2 cascading Table controls are as follows:
  1. Creating the first Table control.
  2. Creating the second Table control.
  3. Link between the two Table controls.

Creating the first Table control

  1. Create a window if necessary.
  2. In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
    Ribbon option
    Click where you want to create the Table control in the window.
  3. The Table control creation wizard starts.
  4. Select "Display data from a file or existing query".
    Table control creation wizard
    Go to the next step of the wizard.
  5. Select the file associated with the Table control. In our example, the CUSTOMER file.
    Selection of data files

    Go to the next step of the wizard.
  6. Select the items that will be displayed in the Table control. In our example, the CustomerName, Company, ZipCode and City items.
    Selection of items

    Go to the next step of the wizard.
  7. Select the search key. In our example, the CustomerNum item.
    Selection of search key

    Go to the next step of the wizard.
  8. Since the other steps are not required for our example, you can exit the wizard.
  9. Validate. The Table control is automatically created in the window.
    Ribbon option
  10. Change the control height with the sizing handles.

Creating the second Table control

The second Table control will be created in the same way.
  1. In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
    Ribbon option
    Click where you want to create the second Table control in the window (below the first one).
  2. The Table control creation wizard starts.
  3. Select "Display data from a file or existing query".
    Table control creation wizard
    Go to the next step of the wizard.
  4. Select the file associated with the Table control. In our example, the CUSTOMER data file.
    Selection of data files

    Go to the next step of the wizard.
  5. Select the items that will be displayed in the Table control. In our example, we are going to select the OrderNum, OrderDate, TotalBT and TotalIOT items.
    Selection of items

    Go to the next step of the wizard.
  6. Select the search key. Caution, the search key must be the item that establishes the link with the first Table control. In our example, this item is CustomerNum.
    Selection of search key

    Go to the next step of the wizard.
  7. Since the other steps are not required for our example, you can exit the wizard.
  8. Validate. The Table control is automatically created in the window.
    Window with the Table controls

Establishing the link between the Table controls

To establish the link between the Table controls, you must:
  1. Make sure that the first Table control returns the value that will be used to filter the second Table control. This can be defined in the Table control description ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
    • Open the description of the first Table control ("Table description" option in the context menu of the control).
    • In the "Content" tab, select the item to store ("Stored item" option). In our example, this option corresponds to the CustomerNum item:
    • Validate the window.
  2. Enable the filter in the second Table control with the Filter property.
    • Select the first Table control and open the control events (F2 key).
    • Go to the "Select a row" event in the Table control to enter the following code:
      SecondTableName.Filter = FirstTableName
      In our example, the corresponding code is:
      Row selection code
The two Table controls are linked. Test the window (click GO in the quick access buttons). Select a customer in the first Table control. The result appears immediately.
Test of cascading Table controls
Using queries
This method uses a query to create and filter the records in the second Table control.
In this example, the customers of the CUSTOMER data file will be displayed in the main Table control. The second Table control will contain the orders of the customer selected in the first Table control.
The steps for creating these 2 cascading tables are as follows:
  1. Creating the first Table control (this step is the same as the one of the first method).
  2. Creating a query with filter used to select the records corresponding to the row selected in the first Table control. This query will be used as source for the second Table control.
  3. Creating the second Table control.
  4. Link between the two Table controls.

Creating the first Table control

  1. Create a window if necessary.
  2. In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
    Ribbon option
    Click where you want to create the Table control in the window.
  3. The Table control creation wizard starts.
  4. Select "Display data from a file or existing query".
    Table control creation wizard
    Go to the next step of the wizard.
  5. Select the file associated with the Table control. In our example, the CUSTOMER file.
    Selection of data files

    Go to the next step of the wizard.
  6. Select the items that will be displayed in the Table control. In our example, the CustomerName, Company, ZipCode and City items.
    Selection of items

    Go to the next step of the wizard.
  7. Select the search key. In our example, the CustomerNum item.
    Selection of search key

    Go to the next step of the wizard.
  8. Since the other steps are not required for our example, you can exit the wizard.
  9. Validate. The Table control is automatically created in the window.
    Ribbon option
  10. Change the control height with the sizing handles.

Creating the query

The steps to create an SQL query with filter are as follows:
  1. Click New in the quick access buttons.
    • In the window that is displayed, click "Queries".
    • The query creation wizard starts.
  2. Specify that you want to create a select query ("Select" option).
    Query creation wizard

    Go to the next step of the wizard.
  3. The query description window appears.
  4. Give a name and a caption to the query:
    Name and caption of the query
  5. In the left section of the description window, select the data file items that will be used (in our example, the ORDER file and the CustomerNum, OrderNum, OrderDate, TotalBT and TotalIOT items).
  6. Double-click the names of the items to add them to the list of query items:
    Selection of items
  7. To apply the filter (selection), select the CustomerNum item in the middle section then, in the right section of the editor, click "Selection condition".
    Selection condition
  8. In the menu that appears, select "New condition...".
  9. In the window that appears:
    • Select the operation ("is equal to" in our example).
    • Select "Parameter" to be able to pass a value selected in the first Table control to the query.
      Characteristics of selection condition
  10. Validate. The query description window is updated:
    Query description
  11. Validate the query description window. The query is displayed in the editor:
    View of the query in the editor
  12. Save the query (Ctrl + S).

Creating the second Table control

To create the second Table control:
  1. Create a window if necessary.
  2. In the ribbon, on the "Creation" tab, in the "Data" group, expand "Table and List Box" and select "Table (vertical)".
    Ribbon option
    Click where you want to create the Table control in the window.
  3. The Table control creation wizard starts.
  4. Select "Display data from a file or existing query".
    Table control creation wizard
    Go to the next step of the wizard.
  5. Select the query previously created to associate it with the Table control. In our example, the QRY_CustomerOrder query.
    Table creation wizard

    Go to the next step of the wizard.
  6. Select the items that will be displayed in the table. In our example, the OrderNum, OrderDate, TotalBT and TotalIOT items are selected.
    Table creation wizard

    Go to the next step of the wizard.
  7. Since the other steps are not required for our example, you can exit the wizard.
  8. Validate. The second Table control is automatically created.
    Window with the two Table controls

Establishing the link between the Table controls

To establish the link between the Table controls, you must:
  1. Make sure that the first Table control returns the value that will be used to filter the query content. This can be defined in the Table control description ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
    • Open the description of the first Table control ("Table description" option in the context menu of the control).
    • In the "Content" tab, select the item to store ("Stored item" option). In our example, this option corresponds to the CustomerNum item:
    • Validate the window.
  2. Initialize the parameter of the query used by the second Table control.
    • Select the first Table control and open the control events (F2 key).
    • Go to the "Selecting a row of..." event to enter the following code:
      QueryName..ParameterName = FirstTableName
      HExecuteQuery(QueryName)
      TableDisplay(SecondTableName)
      In our example, the corresponding code is:
      Row selection code
The two Table controls are linked. Test the window (click GO in the quick access buttons). Select a customer in the first table. The result appears immediately.
Test of cascading Table controls
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/06/2023

Send a report | Local help