In angular slickgrid, column wise sort asc/desc working fine. But removing sort by column header menu not working properly. When i remove the sort, the dataset should be reset to initially loaded dataview. But it maintaining the last sorting order. When i clear the all sorting by grid menu, it working fine. Here i shared my issue case as gif file, anyone please assist me to solve this issue.
1 Answer
You can call dataView.reSort(); to force a resort, that seems to be what you're looking for. The Grid Menu calls dataView.refresh(); and I'm not sure if that would trigger a reSort by the core lib, maybe it does. The header menu only removes a column sort without knowing if there's any sorting left, it basically doesn't keep track of of how many sorting are left and it won't call a reSort neither a refresh but you can call it yourself it will only tell the DataView hey please remove the sort of this column.
Now to add an extra process to the header menu, you'll need to subscribe to the clear-sort header menu command, you can do so by doing something like this (I did not tested it but it should work)
this.gridOptions = {
headerMenu: {
onCommand: (e, args) => {
if (args.command === 'clear-sort') {
const dataView = args.grid.getData();
const sortCols = args.grid.getSortColumns();
// add logic to know if this is last column sort
if (sortCols.length === 0) {
// then call "refresh" or "reSort" either or
// dataView.refresh();
dataView.reSort();
// if that doesn't work then try to call lib SortService from (onAngularGridCreated)
// this.angularGrid.sortService.clearSorting();
}
}
}
}
Note that I'm the author of Angular-Slickgrid and this solution is not part of the lib itself, I might add it later but for now that should be a possible temporary solution.

this.angular Grid.sort Service.clearSorting(). this working fine for my case. If i ask any question means i will share my code snippet.