Currently I group on a hidden field like
GridHelpers.FilterableColumn(columns, m => m.Id).Hidden() .ClientGroupHeaderTemplate(". . . . .");
And as part of the DataSource I added
.DataSource(dataSource =>
{
dataSource
. . . . . .
.Group(g => g.Add(p => p.Id))
;
})
But this seems to alter the way the grid is sorted for display. Is there a hook that I can influence the sorting for the grid?
6 Answers, 1 is accepted
0
Hi Kevin,
When grouping is applied to the Grid data will be sorted internally in order for it to be grouped. If you would like to set specific order for the Grid items in each group I would suggest including the dataSource.sort option. The dojo below outlines the approach:
Specifying a sort with the MVC wrapper would look like this:
Give the approach a try and let me know how it works for you.
Regards,
Viktor Tachev
Progress Telerik
When grouping is applied to the Grid data will be sorted internally in order for it to be grouped. If you would like to set specific order for the Grid items in each group I would suggest including the dataSource.sort option. The dojo below outlines the approach:
Specifying a sort with the MVC wrapper would look like this:
.Sort(s=>s.Add(x=>x.ContactName))
Give the approach a try and let me know how it works for you.
Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kevin
Top achievements
Rank 1
answered on 04 Apr 2019, 01:31 PM
Thank you. This helps a lot. In the post you mention 'Add'ing a column to sort by. Any hints on how to control the "sense" of the sort, like descending or ascending?
0
Kevin
Top achievements
Rank 1
answered on 04 Apr 2019, 02:25 PM
Also when I try to do the following I get an error that there is no such method "Sort". Is this the wrong helper?
.DataSource(dataSource =>
{
dataSource
.Sort(...)
0
Hello Kevin,
The Sort option in the DataSource configuration should be specified after setting the DataSource type. Check out the code snippet below that illustrates a possible DataSource configuration:
Give the approach a try and let me know how it works for you.
Regards,
Viktor Tachev
Progress Telerik
The Sort option in the DataSource configuration should be specified after setting the DataSource type. Check out the code snippet below that illustrates a possible DataSource configuration:
.DataSource(dataSource => dataSource
.Ajax()
.Sort(s=>s.Add(c=>c.CompanyName))
.Read(read => read.Action(
"Customers_Read"
,
"Grid"
))
.PageSize(20)
)
Give the approach a try and let me know how it works for you.
Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kevin
Top achievements
Rank 1
answered on 08 Apr 2019, 12:42 PM
Thank you this works great. Do you have any tips on sorting descending?
0
Hi Kevin,
For specifying a descending sort order you just need to include the Descending() option. Like this:
Let me know if you need further assistance.
Regards,
Viktor Tachev
Progress Telerik
For specifying a descending sort order you just need to include the Descending() option. Like this:
.DataSource(dataSource => dataSource
.Ajax()
.Sort(s => s.Add(c => c.CompanyName).Descending())
.Read(read => read.Action(
"Customers_Read"
,
"Grid"
))
.PageSize(20)
)
Let me know if you need further assistance.
Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.