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

RadGridView Grouping on collection

3 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 23 May 2016, 12:22 AM

Greetings,

I've been using telerik grids for a long time now and been facing an issue lately or lack of my knowledge when it comes to grouping by the collection (not a property). Here's my scenario, I'm showing list of employees in the grid, each employee can have multiple roles and I want to group the data by roles and each group will list all the employees under that role. 

 

I am binding my employees collection to a collectionviewsource and adding the groupdescriptions (collection of employee roles) but it ain't showing anything. I wanted to ask if it is possible to group by the collection in such a scenario? Thank you team telerik     

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 25 May 2016, 08:23 AM
Hello Ali,

You could use a Generic GroupDescriptor in order to achieve the desired behavior.

Please also have a look at the "Custom Grouping" demo from our UI for WPF Demos and the "Sort Group by Different Property" demo from our SDK Samples Browser if you have not done so already.

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sam
Top achievements
Rank 1
answered on 25 Nov 2016, 08:16 AM

Did you find a way to do this Ali?

 

Dilyan I don't think your examples are helpful in this case. Everything you linked to operates on the assumption that a single row will produce a SINGLE grouping key. In this case, each row may belong to multiple groups. See my attached example screen shot. If we were to group by "Employee Roles", the group "Coder" should have employee IDs 2 and 3, and the group "Pleb" would have employee IDs 2 (again) and 1 etc.

 

I suspect internally something like this is happening when using the generic group descriptor:

Items.GroupBy(GenericGroupDescriptorExpression).OrderBy(...) 

which means it's not possible to have a single row entity appearing in more than 1 group.

Any advice would be appreciated.

 

Regards,

Sam

0
Dilyan Traykov
Telerik team
answered on 28 Nov 2016, 11:07 AM
Hello Sam,

Yes, I'm afraid that with the current implementation of the grouping functionality, there is no easy way to achieve the desired behavior. You could modify the ItemsSource of the control to contain duplicate values of the items so that they are displayed once for each group but that will not be an elegant solution.

Regards,
Dilyan Traykov
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
Ali
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Sam
Top achievements
Rank 1
Share this question
or