ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Table control / Table based on a data file
  • Overview
  • Table control based on an independent query (without parameters)
  • Principle
  • Using the HCancelDeclaration/HFreeQuery functions
  • Refreshing the query content
  • Table control based on an embedded query (without parameters)
  • Principle
  • Refreshing the query content
  • Table control based on a query with parameters (independent or embedded query)
  • Principle
  • Passing parameters to the query: .
  • Special cases: Initializing a Table control or using TableDisplay without the taReExecuteQuery constant
  • Special case: Using TableDisplay with the taReExecuteQuery constant
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
Table, List Box and Combo Box controls bound to queries
ODBCNot available with this kind of connection
Overview
A Table, List Box or Combo Box control can be used to display the content of a data file or query.
A Table, List Box or Combo Box control can be bound to:
  • an independent query. This query already exists in the project: you just have to select the desired query from your project's queries.
  • a query included in the control: this query will be created in the wizard for creating the control (table, List Box or Combo Box). This query will be available for this control only and it will be saved with the window (or with the page) that uses it. In this case, the window (or the page) contains all the necessary elements.
  • a query with parameters: this (independent or embedded) query requires parameters to run and to display the result in the Table, List box or Combo box control.
Remark: This help page presents the case of Table controls, but it would be the same for List Box or Combo Box controls.
Table control based on an independent query (without parameters)

Principle

A Table control based on an independent query (without parameters) displays the records from this query.
By default, the query is run and loaded in memory during its first use. The result of a query used in a Table control based on a data file remains in memory when the associated window is closed. This query will not be re-run when it is re-used.
To re-run this query, you must use:

Using the HCancelDeclaration/HFreeQuery functions

  • If HCancelDeclaration is not called, the query will not be executed next time the Table control is initialized (next time the window is open, for example). The data retrieved during the last query execution will be used. If the Table control is based on a query with parameters, see "Table control based on a query with parameters (embedded or not)".
  • If HCancelDeclaration is called, the query will be executed next time the Table control is initialized (next time the window is open, for example).
Remark: HFreeQuery is based on HCancelDeclaration. Their operating mode is identical.
Example:
// Closing code of the window
HCancelDeclaration(TABLE_MyTable.BrowsedFile)

Refreshing the query content

To force the re-execution of the query, use TableDisplay (or ListDisplay for a List Box or Combo Box control) associated with the taReExecuteQuery constant.
Table control based on an embedded query (without parameters)

Principle

A Table control based on an embedded query (without parameters) displays the records from this query.
By default, the query is run and loaded in memory when the Table control is displayed. The result of an embedded query used in a Table control based on a data file is automatically cleared from memory when closing the associated window. This query will be re-run when it is re-used.

Refreshing the query content

To force the re-execution of the query, use TableDisplay (or ListDisplay for a List Box or Combo Box control) associated with the taReExecuteQuery constant.
Table control based on a query with parameters (independent or embedded query)

Principle

When a Table control is bound to a query with parameters (independent or embedded), the parameters must be passed to the query before it is executed.
If these parameters are not specified before the first execution of the query, the query will not be run and the Table control will remain empty.
To pass parameters to the query, you can:
  • specify the parameters one by one by using:
    • the following notation:
      <Query Name>.<Name of Parameter1> = xxx
      <Query Name>.<Name of Parameter2> = xxx
      <Query Name>.<Name of Parameter3> = xxx

      In this case, the query is automatically run when initializing the Table control.
    • the MySource keyword:
      MySource.<Name of Parameter1> = xxx
      MySource.<Name of Parameter2> = xxx
      MySource.<Name of Parameter3> = xxx
    • the indirection:
      {"<Query Name>.<Name of Parameter 1>"} = xxx
      or
      {"<Query Name>"}.<Name of Parameter 1> = xxx
  • specify the parameters at once with HExecuteQuery.
This method for passing parameters can be used in the declaration code of global variables of the window or in the initialization code of Table control for example.
To take these parameters into account, you must use TableDisplay (or ListDisplay for a List Box or Combo Box control).
To re-execute the query with different parameters, you just have to specify these new parameters, and then use TableDisplay (or ListDisplay for a List Box or Combo Box control).

Passing parameters to the query: <Query Name>.<Name of Parameter1>

All the query parameters do not necessarily have to be specified. The query conditions that use unspecified parameters will be ignored. For more details, see Methods for passing parameters to a query.
Remark: If no query parameter is specified before the first query execution, the query will not be run. The Table control associated with the query will remain empty.
Caution: All the query parameters are reinitialized whenever the query is run. The values that have been used beforehand are not stored. You must redefine the query parameters so that it can be run again.

Special cases: Initializing a Table control or using TableDisplay without the taReExecuteQuery constant

  • If no query parameter was modified since the last query execution, the query will not be re-run. The Table control will display the records corresponding to the last execution of the query.
  • Once the query parameters are modified, TableDisplay (or ListDisplay for a List Box or Combo Box control) is used to re-execute the query. The Table control displays all the records corresponding to the specified parameters.

Special case: Using TableDisplay with the taReExecuteQuery constant

To force a query to execute, use TableDisplay (or ListDisplay for a List Box or Combo Box) with the taReExecuteQuery constant.
Reminder: The structure of the query parameters being reinitialized whenever the query is run, don't forget to redefine the requested parameters before using this function.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/24/2022

Send a report | Local help