By default, each of the many powerful, advanced searching and filtering functions in AdapTable take place on the client. And for the vast majority of our users that is fine.
However there will be occasions when a dataset is so huge that you would, additionally or alternatively, prefer to change the data source on the server or perform some search operations on the server. AdapTable is able to help in this scenario, giving you a range of server searching and filtering options so you can choose that which best suits your needs.
If you run Server Search then its your responsibility to perform the search on the server yourself and then to populate the grid with the new dataset. Coming soon will be the Adaptable Server Component which will partner some with innovative FinTech startups to do much of this work for you.
There are 3 steps required in setting up server search.
Choosing which of AdapTable's search functions will take place on the server - this is done through Server Search Options
Listening to search state changes in AdapTable - this is done by subscribing to the SearchChangedEvent
Performing the search on the server by, when necessary, translating our JSON Adaptable Objects into a form meaningful to you, and then sending the data back to the AdapTable via the setGridData api method.
Lets look at each of these steps in turn:
You can decide which search-related functions, if any, will take place on the Server rather than the client.
We offer different options to meet our clients' varying use cases. For example, some like to perform Advanced Search on the server to produce the required Dataset and then to perform further filtering and quick search on the client using this Dataset. Others prefer to perform all searches and filtering on the server. While others will use the server to change the data source but perform all subsequent searching on the client.
You set this through the serverSearchOption property of General Options in AdaptableOptions which is used when initialising the grid.
The 4 available options are:
None - the default. All searching takes place on the client.
If you want to listen to DataSource changes only (in order to change the underlying dataset), but then to perform subsequent searching on the client, choose this option.
AdvancedSearch - you will be notified when an Advanced Search is triggered and then will give AdapTable the matching data. AdapTable will not perform the Advanced Search locally.
AllSearch - you will be notified when an Advanced Search, Quick Search or Column Filter is triggered and then give AdapTable the matching data. Adaptable will not perform any of these searches locally.
AllSearchandSort - you will be notified when an Advanced Search, Quick Search, Column Filter or Grid Sort is triggered and then give AdapTable the matching data. AdapTable will not perform any of the searches locally.
AdapTable will always sort the grid according to the latest grid sort, after you provide it with the new dataset so you don't need to sort the data before passing it to AdapTable.
You can listen to any changes to the grid's current search criteria by subscribing to the On('SearchChanged') event in the Event API.
The SearchChanged event includes in the callback the SearchChangedEventArgs property which provides full and comprehensive information about the current state of ALL the Search and Filter related functions in AdapTable.
Whether the SearchChanged event will fire depends on the serverSearchOption. For example it fires whenever a Data Source changes, but it wont fire if Advanced Search changes and the serverSearchOption is 'none'.
See api documentation for full details.
The event includes a SearchChangedTrigger which is useful if you want to filter which events to subscribe to. For example, if you are only performing Advanced Search on the server, then just listen to changes in Advanced Search and ignore those triggered by other actions.
When you have listened to a searchChanged event and ascertained that you require to filter on the server, you will need to translate the JSON Adaptable Objects provided by the SearchChangedEvent into something meaningful to your data store.
The Adaptable Tools team can help and advise on this but, as each use case is different, there is no "out of the box" solution that we currently provide and it needs to be done a case by case basis.
If the SearchChangedTrigger is DataSource then you will not need to perform any JSON translation, because the DataSource property only contains the name of the selected DataSource which you have provided in your config (typically a StoredProcedure) or Server Filter name.
You will still, of course, need to provide AdapTable with the new dataset.
Once you have translated and performed the search on the server you need to provide your AdapTable instance with the resulting dataset.
If you wish, you can just feed this new data set into the underlying grid normally and AdapTable will automatically pick up the changes.
However AdapTable provides a helpful api method - setGridData - which will take your new data, populate the grid and then internally perform any other actions as needed.