PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Method 1: Table controls linked by ..Filter
  • Creating the first Table control
  • Creating the second Table control
  • Implementing the link between the Table controls
  • Using queries
  • Creating the query
  • Creating the second Table control
  • Implementing the link between the Table controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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, 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 ..Filter
..Filter on a Table control is used to filter the content of a Table control in relation to a value. This value is checked in relation to the search item defined for the Table control. The filter will be applied to the second Table control. The code for row selection will be used to trigger this filter.
In this example, the customers found in CUSTOMER 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" pane, in the "Data" group, expand "Table and list box" and select "Table (vertical)".
    Ribbon option
    Click the position where the Table control will be created in the window.
  3. The wizard for creating a Table control starts.
  4. Select "Display the data found in a file or in an existing query".
    Wizard for creating a Table control
    Go to the next wizard step.
  5. Select the file associated with the Table control. In our example, the CUSTOMER file.
    Selection of data file

    Go to the next wizard step.
  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 wizard step.
  7. Select the search key. In our example, the CustomerNum item.
    Selection of search key

    Go to the next wizard step.
  8. The other wizard steps not being important for our example, end the wizard.
  9. Validate. The Table control is automatically created in the window.
    Ribbon option
  10. Modify the control height with the sizing handles.

Creating the second Table control

The second table will be created according to the same method.
  1. In the ribbon, on the "Creation" pane, in the "Data" group, expand "Table and list box" and select "Table (vertical)".
    Ribbon option
    Click the position where the second Table control will be created in the window (below the first one).
  2. The wizard for creating a Table control starts.
  3. Select "Display the data found in a file or in an existing query".
    Wizard for creating a Table control
    Go to the next wizard step.
  4. Select the file associated with the Table control. In our example, the ORDER file.
    Selection of data file

    Go to the next wizard step.
  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 wizard step.
  6. Select the search key. Caution, the search key must be the item that performs the link with the first Table control. In our example, this item is the CustomerName item.
    Selection of search key

    Go to the next wizard step.
  7. The other wizard steps not being important for our example, end the wizard.
  8. Validate. The Table control is automatically created in the window.
    Window with the Table controls

Implementing the link between the Table controls

To implement 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 configuration is performed in the description of Table control ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
    • Display the description of the first Table control ("Table description" from the popup menu of control).
    • In the "Content" tab, select the item to store ("Stored item" combo box). In our example, this option corresponds to the CustomerNum item:
    • Validate the window.
  2. Enable the filter in the second table with ..Filter.
    • Select the first Table control and display the control processes (F2 key).
    • Position in the "Selecting a table row..." process to type the following code:
      SecondTableName..Filter = FirstTableName
      In our example, the corresponding code is:
      Code for row selection
The two tables are linked. All you have to do is run the window test (GO among the quick access buttons). Select a customer in the first table. The result is immediate.
Test of cascading Table controls
Using queries
This method is using a query to create and filter the records found in the second Table control.
In this example, the customers found in CUSTOMER 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 identical to 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" pane, in the "Data" group, expand "Table and list box" and select "Table (vertical)".
    Ribbon option
    Click the position where the Table control will be created in the window.
  3. The wizard for creating a Table control starts.
  4. Select "Display the data found in a file or in an existing query".
    Wizard for creating a Table control
    Go to the next wizard step.
  5. Select the file associated with the Table control. In our example, the CUSTOMER file.
    Selection of data file

    Go to the next wizard step.
  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 wizard step.
  7. Select the search key. In our example, the CustomerNum item.
    Selection of search key

    Go to the next wizard step.
  8. The other wizard steps not being important for our example, end the wizard.
  9. Validate. The Table control is automatically created in the window.
    Ribbon option
  10. Modify the control height with the sizing handles.

Creating the query

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

    Go to the next wizard step.
  3. The description window of query is displayed.
  4. Give a name and a caption to the query:
    Name and caption of query
  5. In the left section of the description window, choose the 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 items to add them into the list of query items:
    Selection of items
  7. To perform the filter (selection), select the CustomerNum item in the middle section then, in the right section of the editor, click the "Selection condition" button.
    Selection condition
  8. In the menu that is displayed, select "New condition...".
  9. In the window that is displayed:
    • Select the operation ("is equal" 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 description window of query is upated:
    Query description
  11. Validate the description window of query. The query is displayed in the editor:
    Displaying 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" pane, in the "Data" group, expand "Table and list box" and select "Table (vertical)".
    Ribbon option
    Click the position where the Table control will be created in the window.
  3. The wizard for creating a Table control starts.
  4. Select "Display the data found in a file or in an existing query".
    Wizard for creating a Table control
    Go to the next wizard step.
  5. Select the query that was created beforehand to associate it with the Table control. In our example, the QRY_CustomerOrder query.
    Wizard for table creation

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

    Go to the next wizard step.
  7. The other wizard steps not being important for our example, end the wizard.
  8. Validate. The second Table control is automatically created.
    Window with the two Table controls

Implementing the link between the Table controls

To implement 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 configuration is performed in the description of Table control ("Content" tab, "Stored item" option). In our example, the stored item will be CustomerNum.
    • Display the description of the first Table control ("Table description" from the popup menu of control).
    • In the "Content" tab, select the item to store ("Stored item" combo box). In our example, this option corresponds to the CustomerNum item:
    • Validate the window.
  2. Initializing the parameter of the query used by the second Table control.
    • Select the first Table control and display the control processes (F2 key).
    • Position in the "Selecting a table row..." process to type the following code:
      QueryName..ParameterName = FirstTableName
      HExecuteQuery(QueryName)
      TableDisplay(SecondTableName)
      In our example, the corresponding code is:
      Code for row selection
The two Table controls are linked. All you have to do is run the window test (GO among the quick access buttons). Select a customer in the first table. The result is immediate.
Test of cascading Table controls
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment