Replies
Thanks for the update.
In the meantime I adopted your code and this is what I have working now. Posting it so others coming across this post can compare and contrast.
We have a column that is always sorted descending by default, this played well since it allowed the unsort to become a resort on that default column and the CSS and visual clues worked nicely of us.
features: [{
name: 'Sorting',
type: 'remote',
mode: 'single',
applySortedColumnCss: false,
// remove default sort background color but leave visual clue in header
columnSorting: function (evt, ui) {
if ((ui.owner.option("firstSortDirection") == ui.direction) && ui.owner.grid.dataSource.settings.sorting.expressions.length != 0) {
if (ui.owner.grid.dataSource.settings.sorting.expressions[0].fieldName == ui.columnKey && ui.columnKey != "NameOfYourDefaultSortedColumn") {
// our grid has a default sort column so sort by it in order to remove current sort.
$(gridElement).igGridSorting("sortColumn", "NameOfYourDefaultSortedColumn", "descending");
return false;
}
}
return true;
}
}]
Thanks again for your help.
Regards
Aidan
Hi
Unfortunately this doesn't work.
When I asked the question the grid in question had a mode of "multi", so I assumed that was part of the reason the code didn't work.
Since then, the multiple sort requirement was been dropped so I retried this code with a grid with mode = single but it still fails.
1. On the third click (back to firstSortDirection), the unsort does not occur and further clicking has no effect.
2. Clicking on a new / different column heading has no effect but the header gets the "sorted" background color, and the previous column retains its "sorted" background color.
Regards
Aidan