Linking a Data Source to a Grid Using an Expression

In addition to connecting a data source to a data grid directly, you can use the SetGridDataSource function. This will link the specified data source to a grid and can also be used to automatically generate the grid's structure to match that of the data source. This is especially useful when working with an in-memory data source, as this function is the only way to connect it to a data grid.

Implementation:

  1. Open the Expression Editor where you want to add the expression.
  2. Enter the following:

SetGridDataSource( GridKeyword, DataSourceName, ItemsPerPage, AutoGenerateColumns, ModelReference );

  1. Replace GridKeyword with the keyword for the data source grid to use.
  2. Replace DataSourceName with the name of the data source to link.
  3. Replace ItemsPerPage with a number representing the amount of rows to display per page in the grid.
  4. (Optional) Replace AutoGenerateColumns with 1 if the grid's columns should be automatically set to match the columns in the data source. If not used, the grid will use the pre-configured grid definition.
  5. (Optional) Replace ModelReference with the reference for the model associated with the data source. This is only required if this function is called outside the context of a model, such as in a web page expression.
  6. Save the expression.