igniteui-angular
igniteui-angular copied to clipboard
IgxGrid : Change default sorting direction for grouped column
Whenever we group a column the default sorting is always ascending.
Is there a way to change the default sorting direction to descending?
- igniteui-angular version: 13.1.8
- browser: Chrome
Hi, there is no property that would change the default sorting direction, but you can sort the grid as you group columns in the direction you want in the onGroupingDone event:
this.grid1.sort([ { fieldName: e.groupedColumns[0].field, dir: SortingDirection.Desc, ignoreCase: true, }, ]);
Sample here
@tishko0 Can we create a sorting strategy where we can always put empty values at the bottom?
Hey there.
Yes, this is possible, however there is no exposed method that would do it, so you will have to implement a custom sorting strategy to do so. I have prepared a sample here
In the sample, I have created two sorting methods(one for ascending and one for descending) that will sort the null values to the end.: compareValuesAsc and compareValuesDsc;
Then I have overwritten the comparer in the default class to use those methods so the sorting will be as per the custom sorting methods:
if (reverse) { return this.compareValuesAsc(a, b); } else return this.compareValuesDsc(a, b);
Please check the sample and let me know if you have any questions.
There has been no recent activity and this issue has been marked inactive.