This is a migrated thread and some comments may be shown as answers.

Group by column in descending order by default

2 Answers 490 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yih Wern
Top achievements
Rank 1
Veteran
Yih Wern asked on 14 Oct 2020, 05:45 PM

Hi Everyone,

I am trying to set the Kendo Grid with Group by specific column by default, so I have used the code snippet as shown below:

@(Html.Kendo().Grid<StudentRecord>().Name("Grid")

.Groupable()

.Sortable()

.GroupPaging(true)

.Group(x => x.Add(y => y.StartYear))

 

And I realised it always displays the StartYear groups in ascending order by default.

Please advise how I could set the StartYear groups to sort in descending order by default.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 19 Oct 2020, 05:17 PM

Hello,

You can try setting the Sort of the Groupable method:

 .Groupable(g=>g
    .Sort(e=>e.Dir(System.ComponentModel.ListSortDirection.Descending)
    ))

Regards,
Plamen
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Yih Wern
Top achievements
Rank 1
Veteran
answered on 28 Oct 2020, 06:21 PM

Hi Plamen,

Appreciate your response and I have tried, but it did not work as expected.

My requirement is to sort by the StudentYear, and I managed to find the solution from this post:

https://www.telerik.com/forums/chaning-group-default-sort

Thanks and regards

Tags
Grid
Asked by
Yih Wern
Top achievements
Rank 1
Veteran
Answers by
Missing User
Yih Wern
Top achievements
Rank 1
Veteran
Share this question
or