Datasources
Overview
The @genesislcap/grid-pro
package provides a collection of grid-pro datasource components. These components are responsible for fetching data for the Genesis Grid Pro component.
<grid-pro-client-side-datasource>
Client-side features
- Sorting: Order by any column, ASC or DESC.
- Filtering:
- Filtering options are automatically generated based on the resource’s metadata.
- String Filters:
- contains
- not contains
- equals
- not equals
- starts with
- ends with
- blank
- not blank
- Number/Date Filters:
- equals
- less than
- less than or equal
- greater than
- greater than or equal
- in range
- Filter Combinations (Max 2 filters can be combined):
- filter1 AND filter2
- filter1 OR filter2
Client-side notes
- Works with both
DATASERVER
andREQUEST_SERVER
resources. - Operations like sorting and filtering are performed on the client-side.
- Suitable for datasets that are small to medium in size and can be entirely loaded into the client.
Usage example
<rapid-grid-pro enable-row-flashing enable-cell-flashing>
<grid-pro-client-side-datasource
resource-name="ALL_TRADES"
criteria="INSTRUMENT_ID == 'TSLA'"
></grid-pro-client-side-datasource>
</rapid-grid-pro>
<grid-pro-server-side-datasource>
Server-side features
- Sorting: Order by any INDEX column/field, ASC or DESC.
- This is a server limitation. For each column that needs to be sortable, you must have an index for it.
- By default, sorting is disabled on all columns, but wherever a valid index is detected from the metadata, that column (field) will have sorting enabled.
- If the user attempts to force
sortable
, we'll check its validity, warn in the logs if not, and mention other available indices, if any.
- Filtering:
- Filtering options are automatically generated, based on the resource’s metadata.
- String Filters:
- blank
- contains
- equals
- notBlank
- notEqual
- wordStartsWith
- Number Filters:
- equals
- notEqual
- greaterThan
- greaterThanOrEqual
- lessThan
- lessThanOrEqual
- inRange
- blank
- notBlank
- Date Filters:
- equals
- lessThan
- greaterThan
- inRange
- isToday
- blank
- notBlank
Server-side notes
- Operations like sorting and filtering are pushed to the back end.
- Filtering uses
CRITERIA_MATCH
param. - Sorting uses
ORDER_BY
param. - Once filtering/sorting is applied, the datasource component resets itself, starting a new stream with the updated params.
- Filtering uses
- Limitations:
- Sorting can only be applied to index fields/columns.
ROWS_COUNT
doesn’t reflect the correct amount when aCRITERIA_MATCH
(filtering) is applied. For example, if a resource has 100 records and a criteria returns only 50, the server still reports 100. We have to calculate this manually.
- Suitable for large datasets where only a subset of data is loaded into the client based on user interactions.
Usage example
<rapid-grid-pro enable-row-flashing enable-cell-flashing>
<grid-pro-server-side-datasource
resource-name="ALL_TRADES"
criteria="INSTRUMENT_ID == 'TSLA'"
></grid-pro-server-side-datasource>
</rapid-grid-pro>
Common attributes and properties
There are many attributes that can be set on a datasource component. These attributes can be used to customize the behavior of the datasource and the grid component. Below is a list of some of the most commonly used attributes.
Resource-specific
Some resource attributes and properties are DATASERVER
or REQUEST_SERVER
specific, while others can be used with both.
These are used to define the resource that the datasource will be fetching data from. The resource-name
attribute is required for both DATASERVER
and REQUEST_SERVER
resources.
DATASERVER and REQUEST_SERVER attributes
Name | Type | Description | Example |
---|---|---|---|
resource-name | string | Required attribute. The name of the target Data Server query or Request Server requestReply . |
|
is-snapshot | boolean | Request a snapshot from the server. Default: false |
|
criteria | string | Clients can send a Groovy expression to perform filters on the query server; these remain active for the life of the subscription. |
|
max-rows | number | Maximum number of rows to be returned as part of the initial message and any additional MORE_ROWS messages. This will not affect the number of rows displayed. |
|
view-number | number | The desired view/page you want data from. |
|
DATASERVER and REQUEST_SERVER properties
Name | Type | Description | Example |
---|---|---|---|
:rowDataMapper | Function | Function to map the row data before it is sent to the grid. The function should return an array of objects, where each object represents a row in the grid. |
|
Criteria use groovy expressions to filter responses from the back end.
DATASERVER-only attributes
Name | Type | Description | Example |
---|---|---|---|
fields | string | This optional parameter allows you to select a subset of fields from the query if the client is not interested in receiving all of them. |
|
max-view | number | Maximum number of rows to track as part of a client "view". |
|
moving-view | boolean | Default: false . If true, when the maximum number of rows defined in max-view is reached, the Data Server will start discarding the oldest rows (in terms of timestamp) and sending newer rows. If false, updates in the server will be sent to the front end regardless of order. Note that this will only update the UI; no changes will be performed in the database. |
|
order-by | string | This option can be used to select a Data Server index (defined in the Data Server query ), which is especially useful if you want the data to be sorted in a specific way. By default, Data Server rows are returned in order of creation (from oldest database record to newest). |
|
reverse | boolean | Default: false . This option changes the Data Server index iteration. For example, if you are using the default index, the query will return rows in order from the newest database records to the oldest. |
|
REQUEST_SERVER-only attributes
Name | Type | Description | Example |
---|---|---|---|
disable-polling | boolean | This option disables polling if set to true (data updates for the grid will not be fetched automatically). Defaults to false. |
|
polling-interval | number | This option enables you to set a custom polling frequency (in milliseconds) for a Request Server resource. Note that this option only works with Request Server resources; if your resource is a Data Server query , your grid is updated in real time. |
|
request-auto-setup | boolean | This option, if set to true, will automatically set up the request based on the datasource's metadata. Defaults to false. |
|
REQUEST_SERVER-only properties
Name | Type | Description | Example |
---|---|---|---|
:request | any | Similar to fields but for Request Server scenarios. This optional parameter enables you to specify request fields, which can include wildcards. |
|
Datasource-specific attributes
There are additional attributes that can affect the behaviour of a datasource component.
<grid-pro-client-side-datasource>
Name | Type | Description | Example |
---|---|---|---|
restart-on-reconnection | boolean | If set to true, the resource data will be reloaded upon a reconnection event. Default: false |
|
keep-col-defs-on-clear-row-data | boolean | If set to true, column definitions will be retained upon a restart or clearRowData event. Default: false |
|
<grid-pro-server-side-datasource>
Name | Type | Description | Example |
---|---|---|---|
pagination | boolean | Enables pagination if set to true (default: false); otherwise, the behavior will be infinite-scroll. |
|
zero-based-view-number | boolean | If set to true, the starting VIEW_NUMBER will be zero-based (starting from 0 instead of 1). Default is false. |
|
live-updates | boolean | Enables live updates for the grid if set to true (default: false). |
|
Summary
- Client-Side Datasource: Suitable for smaller datasets where all data can be loaded into the client. Operations like sorting and filtering are performed on the client side.
- Server-Side Datasource: Ideal for large datasets, where operations are pushed to the back end to ensure performance and consistency. Data is fetched as needed, based on user interactions.