Initial sorting of a datatable

My datatable has sorting set to ‘server’ for a few columns.

How can I make the datatable sort its contents by any of these columns, already when it is first displayed?

(Without me having to click the column headers first)


Simple solution - just add the sorting parameters to the url: property of the datatable.

Only problem with this solution, is that when first time clicking the column header, to sort, it will be again sorted ASCending order, which it already was…


You can use apply markSorting method:

dataTable.markSorting(columnId, "asc");

Works perfect. Thanks :slight_smile:

First click on the same header after using grid.markSorting(id, “asc”) does not switch sort direction. Is there anything else that needs to be set in config or is this a bug?

Note: for grid.markSorting(id, “desc”) - first click on the header works correctly

Please take a look at the snippet:

Hi @dyankin ,
I can confirm the issue. Thank you for the report! We will fix it.