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:
- Open the Expression Editor where you want to add the expression.
- Enter the following:
SetGridDataSource( GridKeyword, DataSourceName, ItemsPerPage, AutoGenerateColumns, ModelReference );
- Replace GridKeyword with the keyword for the data source grid to use.
- Replace DataSourceName with the name of the data source to link.
- Replace ItemsPerPage with a number representing the amount of rows to display per page in the grid.
- (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.
- (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.
- Save the expression.