Sort Datatable by server in the first request.

How to sort datatable by server in the first request but loading 10 rows and when rotating the mouse loads more rows.
I tried with this.sort('id','desc') but get this error " can't access property "id", t is undefined ".
I also tried with scheme:{
$sort:{
by:"id",
dir:"desc",
as:server
}
}
but don't make the sort.

Comments

  • edited May 15

    Hello, @ Tarcantos

    Sorting is a client-side feature, i.e. it works only with the data that exists in the component. Dynamic loading requests a batch of data when the user scrolls down to the rows that were not loaded yet. Until then, the datatable simply reserves the space and position for them, but they cannot be sorted (as there's no item ID to refer to). That is the reason for the error you've got.

    Speaking about

    scheme:{
      $sort:{
        by:"id",
        dir:"desc",
        as:server
      }
    }
    

    That is possible to use that version but combined with a pager, that would allow you to display a new chunk of sorted data. Please, check the snippet here: https://snippet.webix.com/o46i3g7j

    But in general, in the case of dynamic loading, you can use server-side filtering and server-side sorting ( that means component will reload data on sorting and filtering )
    Here is the snippet: https://snippet.webix.com/jfjj5dkv

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion