igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

IgxGrid : Change default sorting direction for grouped column

Open KaushikEDS opened this issue 2 years ago • 3 comments

Whenever we group a column the default sorting is always ascending. image

Is there a way to change the default sorting direction to descending?

  • igniteui-angular version: 13.1.8
  • browser: Chrome

KaushikEDS avatar Jun 17 '22 09:06 KaushikEDS

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 avatar Jun 20 '22 08:06 tishko0

@tishko0 Can we create a sorting strategy where we can always put empty values at the bottom?

KaushikEDS avatar Jul 19 '22 13:07 KaushikEDS

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.

tishko0 avatar Jul 21 '22 10:07 tishko0

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Sep 20 '22 00:09 github-actions[bot]