Sort reset is not working.

1 Answer 120 Views
Grid Sortable
Mithali
Top achievements
Rank 1
Mithali asked on 07 Feb 2024, 09:49 PM

On the grid the sort seems to be working fine. 
But when I am doing the next search after clearing the results in the grid the sort function is not resetting. 

 

  clear() {
    this.firstName = "";
    this.lastName = "";
    localStorage.removeItem("firstName");
    localStorage.removeItem("lastName");
    this.orgName = "";
    this.rowData = [];
    this.filteredRowCount = 0;
    // this.grid.filterService.clear();
    this.grid.filter = undefined;
    this.grid.sort = [];
    this.state.sort = [];
    const emptySortState: DataStateChangeEvent = {
      sort: [],
      skip: 0,
      take: this.pageSize
    };
    this.onDataStateChange(emptySortState);
    this.grid.data = this.rowData;
    this.grid.columns.forEach((column: ColumnComponent) => {
      column.filter = undefined;
    })
    this.filter = { logic: 'and', filters: [] };
  }

 

1 Answer, 1 is accepted

Sort by
0
Zornitsa
Telerik team
answered on 08 Feb 2024, 01:24 PM

Hi Mithali,

In order to programmatically clear the operation descriptors, including sorting, the developer should make sure to reload the data in the Grid with the specified empty descriptors for the changes to be reflected.

For a better understanding, I have prepared a StackBlitz example, in which you can observe how the operation descriptors are cleared on a button click:

In case the issue still persists, please provide more details on the configuration of the Grid component and its functionality on your side. Ideally, sharing a runnable example in which the problematic behavior can be replicated would be very helpful in further troubleshooting and identifying a possible cause of the issue. 

Regards,
Zornitsa
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Grid Sortable
Asked by
Mithali
Top achievements
Rank 1
Answers by
Zornitsa
Telerik team
Share this question
or