Server-side Sorting
This section covers Server-side Sorting using the Server-side Row Model.
Enabling Sorting
Sorting is enabled in the grid via the sortable column definition attribute. Some example column
definitions with sorting enabled are shown below:
For more details on sorting configurations see the section on Row Sorting.
Sorting on the Server
The actual sorting of rows is performed on the server when using the Server-side Row Model. When a sort is applied
in the grid a request is made for more rows via getRows(params) on the
Server-side Datasource. The
supplied params includes a request containing sort metadata contained in the sortModel property.
An example of the contents contained in the sortModel is shown below:
Notice in the snippet above that the sortModel contains an array of sorts for each column that has
active sorts in the grid. The column id and sort type can then be used by the server to perform the actual sorting.
Example: Server-side Sorting
The example below demonstrates server-side sorting. Notice the following:
- Try single / multi column (using shift key) sorting by clicking on columns headers.
- All columns have sorting enabled using the
defaultColDefgrid options property withsortable=true. - The server uses the metadata contained in the
sortModelto sort the rows. - Open the browsers dev console to view the
sortModelsupplied in the request to the datasource.
Fake Server Implementation
Most of the Server-side Row Model examples include a fake server that generates SQL to imitate how a real server might use the requests sent from the grid. These examples use AlaSQL which is a JavaScript SQL database that works in browsers.
However note that the Server-side Row Model does not impose any restrictions on the server-side technologies used.
Next Up
Continue to the next section to learn about Server-side Filtering.