Server-side Filtering
To filter server-side, use a function as the
data prop and set shouldReloadData.filterValue: true on the <DataSource /> component (with lazyLoad and livePagination, this is the default).The
data function prop is then called again on every filter change, with an object argument that includes the filterValue property, so the filters can be sent to the server for performing the correct filtering operations. The rows it returns are shown as they are - they are not filtered again in the browser.Obviously the filtering can be combined with sorting, grouping, etc.
It's up to the
data function prop to send the correct parameters to the server for remote operations.The returned JSON can include both
- a
totalCountproperty (number) and - a
totalCountUnfilteredproperty (alsonumber) - to inform the<DataSource />of the size of the data, both with and without the applied filters.
#
Server-side filtering example
All the filtering in this example happens server-side.
This example also does server-side (multiple) sorting.
loading demo…
When the filter value for a column matches the empty value - as specified in the
filterTypes.operator.emptyValues - that value is not sent to the server as part of the filterValue array.When doing server-side filtering, it's your responsability as a developer to make sure you're sending the correct filtering parameters to the server, in a way the server understands it.
This means that the filter values, the filter type and the names of the operators are known to the server and there is a clear convention of what is supported or not.
Batch filtering#
In order to reduce the number of requests sent to the server, filtering will be batched by default.
Batching is controlled by the
filterDelay prop, which, if not specified, defaults to 200 milliseconds. This means, any changes to the column filters, that happen inside a 200ms window (or the current value of filterDelay), will be debounced and only the last value will be sent to the server.If you want to prevent debouncing/batching filter values, you can set
filterDelay to 0.