The Adaptable Blotter frequently lists the (distinct) values which are associated with a particular column.
These appear in a number of places including:
Column Values tab of the Query Builder
Column Filter dropdown
Bulk Update function
But where do these values come from and how do we know what to display?
There are 3 different ways in which we fetch these values depending on your preferences.
By default AdaptableBlotter.JS will retrieve all the distinct values for the column currently in the grid.
The method to get this data has been refactored many times to ensure it is very performant.
Another alternative is to set - for each column - the values which can be displayed.
These are known as Permitted Column Values.
The object is straightforward; it contains 2 properties: 'column' (string) and permittedValues (string array).
These can be set at design-time via Predefined Config.
Alternatively they can be set at run-time via the BlotterAPI using the uiSetColumnPermittedValues method.
This method takes the name of the column and an array of column values as the 2 parameters.
It is expected that Permitted Column Values will be set infrequently for each column, usually just once.
If you need to changes these values regularly then the Dynamic Column Values option (below) might be more suitable.
Permitted Column Values takes precedence over fetching distinct column values.
The third option is to provide - at runtime - Dynamic Column Values.
In this case the Blotter will call a user-provided callback function each time that a list of column values is required.
This function is set at design time when the Blotter is defined.
The property is getColumnValues in Query Options section of the AdaptableBlotterOptions object - see BlotterOptions for more information.
The callback must take the form: (column: string) => Promise<IServerColumnValues>. In other words, it takes the name of the column in question as the only parameter and returns a Promise that will contain list of column values to display and whether to show display or raw values.
If you use this option, then you have to provide Dynamic Column Values for every Column.
There is currently no means to configure the Blotter only to use it for some, specified, columns.
If the column values to be returned have not changed since the last time this function was run for the same column, you can return null.
The Adaptable Blotter will then display what you sent on the previous occasion.
Dynamic Column Values takes precedence over Permitted Column Values.
What happens if you have hundreds of thousands of rows in your grid? How can you cap the number of column values displayed so that the list becomes manageable?
The solution is to use the (numeric) maxColumnValueItemsDisplayed property in AdaptableBlotterOptions.
If this property is set (the default is that it is not) the Adaptable Blotter will cap the number of values displayed in the grid to value of the property.
If it is set, the maxColumnValueItemsDisplayed property will be used irrespective of which of the above methods is used to retrieve the column values.