excluding first row from sorting

1 Answer 337 Views
Grid
shahzia
Top achievements
Rank 1
shahzia asked on 06 May 2021, 09:00 AM

is their any possible way to exclude the first row from sorting in kendo grid apart from the new sticky row feature? ( I am looking for a solution that would work in all browsers) 

1 Answer, 1 is accepted

Sort by
0
Hetali
Telerik team
answered on 06 May 2021, 11:09 PM

Hello Shahzia,

In order to prevent the first row of the Kendo UI Grid from sorting, use the following custom approach in the sortChange event when there is no initial sort or while loading when there is an initial sort:

public sort: SortDescriptor[] = [
  {
    field: 'ProductName',
    dir: 'asc'
  }
];

private loadProducts(): void {
  var arr = this.products.slice(1, this.products.length);
  var sortItems = orderBy(arr, this.sort);
  sortItems.unshift(this.products[0]);

  this.gridView = {
    data: sortItems,
    total: this.products.length
  };
}

In this StackBlitz example, the first row of the Kendo UI Grid is excluded from sorting.

Let me know if this helps or if I can further assist you.

Regards,
Hetali
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
Grid
Asked by
shahzia
Top achievements
Rank 1
Answers by
Hetali
Telerik team
Share this question
or