Sort groups themselves by a field other than the group field property

2 Answers 2656 Views
Grid
Garrett
Top achievements
Rank 2
Garrett asked on 25 Jun 2012, 09:21 PM
I have a grid containing sports teams and their associated stats, grouped by the team name. I want to sort the groups themselves (not the stats inside of the groups) by newest to oldest stats. Each stat has a timestamp for when it was added to the system.

Basically I need to list the stats of the teams who have most recently played a game at the top of the list.

Anyone know who to accomplish this?
Alexander Valchev
Telerik team
commented on 28 Jun 2012, 02:03 PM

Hello Garrett,

I am not sure if I understood you correctly.
In case you want to group by team name and sort the groups themselves not by their name, but by date - I am afraid that this scenario is not possible. When the dataSource is grouped, the its data is sorted ascending or descending by the field it is grouped by.

If you want to group by field: team and sort the records inside the groups by date, you could use the following configuration:
var dataSource = new kendo.data.DataSource({
    group: { field: "team" },
    sort: { field: "date", dir: "desc" },
    //.....
});

In this fiddle you can see the approach in action. I hope this helps.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Garrett
Top achievements
Rank 2
commented on 28 Jun 2012, 04:01 PM

Thanks for the reply, unfortunately I was looking for the first scenario, to be able to sort the groups themselves by date. For the time being I can live without the date sorting, but would this be something you guys would be planning to add in the future?

Thanks again for the reply, really appreciate it!
Alexander Valchev
Telerik team
commented on 03 Jul 2012, 07:54 AM

Hello Garrett,

I am afraid that the implementation of such functionality is not in our immediate plans. I would recommend submitting this as a feature request in our user voice forum - a place where other users would be able to comment and vote for it. If it turns out to be popular, we will consider adding it in one of our future releases.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Dina
Top achievements
Rank 1
commented on 17 Jul 2017, 05:45 PM

It is very disappointing that 5 years later you still did not implement that. It is very about Telerik. It looks grate but little details like this ruing everything.

2 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 20 Jul 2017, 12:28 PM
Hi Dima,

I have already responded to you in the ticketing system but I will share my response here in case anyone else comes across this post. I am sorry to hear that you are disappointed with the lack of a custom group sort compare functionality. However, feature implementation in our roadmap and priorities depend largely on the business value and customer demand for specific components and features. We strive to implement functionalities which are in high demand first. We also have a Feature Acceleration Programme separate offering which allows a customer to negotiate a certain component or functionality to be implemented on demand or sooner than our roadmap implies. 

Currently, the groups are sorted ascending by default in alphabetical order. The sort which is applied to the column headers sorts the group items, not the groups themselves.

At present, there are two options to achieve the desired custom group sort:

1) Use server operations and provide the groups as desired:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-serverSorting

2) If you use client operations, some custom logic will be required.

- Provide another field which holds the group priority and when grouping occurs, group by that field instead-

You will need a column template to show the corresponding field value, e.g. days of the week order

- And a group header template 

Here is a runnable example with the days of the week:

http://dojo.telerik.com/UgoyO

Finally, please take the time to cast a vote in the UserVoice form at:

http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/suggestions/16620391-support-custom-sorting-for-datasource-groups

The most popular ideas are considered for priority implementation.

Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualisation (charts) and form elements.
Dina
Top achievements
Rank 1
commented on 30 Jul 2017, 05:14 PM

Tnks a lot Alex

Suggested solution works well for me

Andrew
Top achievements
Rank 1
commented on 25 Apr 2018, 02:45 PM

I'm using Kendo MVC 2018 R1 and it appears that I am now able to access the items from the group header template.   I wasn't able to successfully do this in v2017.1.   This allows me to sort by one column (object.ID or SortOrder) and display the corresponding field (object.Description), which is the same for all items in the group.  

 

.ClientGroupHeaderTemplate(@"#= items[0].Description #")
0
Alex Hajigeorgieva
Telerik team
answered on 29 Nov 2018, 02:49 PM
Hello,

I am pleased to let you know that thanks to the popularity of this feature request we have now completed it and it will be part of the built-in options as of 2019 R1 which is planned for 16th January 2019.

Here is the public issue for your reference:

https://github.com/telerik/kendo-ui-core/issues/4024

Kind Regards,
Alex Hajigeorgieva
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.
Michael
Top achievements
Rank 2
Iron
Iron
Iron
commented on 07 Mar 2019, 05:57 PM

Will the online MVC demos be updated or expanded to show a real example off this - I see nothing under the grid Sorting examples that show how to implement the new capability.
Alex Hajigeorgieva
Telerik team
commented on 11 Mar 2019, 02:18 PM

Hello, Michael,

We have an example in the documentation section at:

https://docs.telerik.com/aspnet-mvc/api/Kendo.Mvc.UI.Fluent/GridGroupableSortSettingsBuilder

I have now added an internal task to our backlog as I do believe it is a great idea to have this in the official demos section.

However, in case you need further assistance with this functionality for the UI for ASP.NET MVC wrappers, please let me know and I can provide you with a runnable example if needed.

Regards,
Alex Hajigeorgieva
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.
Michael
Top achievements
Rank 2
Iron
Iron
Iron
commented on 11 Mar 2019, 02:23 PM

That is super - thanks so much!
Joshua
Top achievements
Rank 1
commented on 08 Oct 2020, 06:52 PM

Is this possible for the Jquery/Angular.js version of the grid?
Alex Hajigeorgieva
Telerik team
commented on 09 Oct 2020, 10:17 AM

Hello, Joshua,

For the jQuery Kendo UI Grid, you can use the columns.groupable.sort.compare function and the data source group.compare function.

Regards,
Alex Hajigeorgieva
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).

Marouane
Top achievements
Rank 1
commented on 19 Oct 2020, 11:53 PM

Hi, I have a grid that uses a datasource with group option, combining this with the example you have provided that not work.  

Here is the example with group definition at the level of the datasource which breaks the group sort defined at the level of the column.

https://dojo.telerik.com/ULosEbeG/2

Could you please provide me a working example ?

Thx

 

 

Marouane
Top achievements
Rank 1
commented on 20 Oct 2020, 12:07 AM

My bad, you have provided two link, the second one links to how to use sort group with datasource. I will try it.

 

Thx

Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 14 Mar 2022, 03:39 PM

Is this possible with KendoReact?
Stefan
Telerik team
commented on 17 Mar 2022, 08:19 AM

Hello,

For KendoReact we have a logged item for this functionality:

https://github.com/telerik/kendo-react/issues/633

I have added your request there as well.

Tags
Grid
Asked by
Garrett
Top achievements
Rank 2
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or