Kendo UI Grid for Angular 2 Server Side Sorting

1.4k views Asked by At

I'm following this Grid Sorting example on the Kendo documentation, but I need guidance in getting this to work as a server-side sort instead of a client-side sort.

I'm thinking the "toOdataString()" method used in their Data-Binding example should somehow be able to accept the sortDescriptors as well. Can anyone advise on whether or not this is supported, and if so, how do I achieve it?

Thanks a mil'.

1

There are 1 answers

0
knikolov On BEST ANSWER

The data binding example that you linked also supports sorting you just need to enable it:

  1. Enable the option on the Grid:

    [sortable]="{ mode: 'multiple' }"
    [sort]="sort"
    
  2. Pass the sort parameters in the dataStateChange event:

    this.grid.dataStateChange
        .do(({ skip, take, sort }: DataStateChangeEvent) => {
            this.skip = skip;
            this.pageSize = take;
            this.sort = sort;
        })
        .subscribe(x => this.service.query(x));
    

Check this plunkr.