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

Group by a different field to group title

3 Answers 361 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 03 Feb 2017, 04:02 AM

Hi guys, I've a case where I'm grouping with the grid, but want to sort in a different order.

E.g. by default if my group data field has values A, B, C, D this would be the group order.

I have data that is sorted by sections of data, that have an order the client wants displayed in a priority order.

To simplify it something like:

Display Field Value    Sort Field Value

A                                2

B                                4

C                                1

D                                3

I want the grouping text to be A, B, C, D, but the order to be C, A, D, B as per the sort field value (a field not to be visible).

I haven't been able to find anyway to do this. Any help greatly appreciated.

3 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 06 Feb 2017, 01:27 PM
Hello Andre,

In general, the groups in a grouped Grid can be sorted only ascending or descending based on the default sorting for the respective column field.

You can achieve the desired behavior by some custom implementation, for example using a column template to show one field's value in a column, bound to the field you would like to sort by, and the columns.groupHeaderTemplate to provide a function that will retrieve the desired information for the group header, e.g.:

http://dojo.telerik.com/OYegi/2

However, please mind that this approach is not supported, and may have some undesired side effects. I can recommend the Progress Professional Services for any feature customization or custom implementation:

https://www.progress.com/services/outsourcing/feature-customization

Let me know if you are interested, and I will arrange for someone from the team to contact you.

Regards,
Dimiter Topalov
Telerik by Progress
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 visualization (charts) and form elements.
0
Revati
Top achievements
Rank 1
answered on 23 Aug 2018, 08:02 PM
Hi Dimiter, could you please provide an example of the above? I want to group by Country and sort by the count of states in each country. How can that be achieved?
0
Konstantin Dikov
Telerik team
answered on 28 Aug 2018, 07:40 AM
Hi Revati,

The dojo example in the previous post shows how to bound a column to one field, but display another field`s values in it. In your case, you will need another field in the dataItems that will be used for grouping and sorting the records as per your requirements (maybe CountryOrder). However, since the number of states could be equal for different countries, you might need to create a value with the number of states as prefix and the country name as suffix and populate it for each record in the database. Once that field is added to the records, you could bound the column to the CountryOrder field and group by it. Using the templates you can show the Country field values.


Regards,
Konstantin Dikov
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.
Tags
Grid
Asked by
Andre
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Revati
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or