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

Making items appear in multiple groups

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Francisco Amador
Top achievements
Rank 1
Francisco Amador asked on 14 Jun 2010, 08:45 PM
The project that I'm working on requires me to display items in a grid which may have to appear in multiple groups. So for example, I may have a book that belongs to two Category groups, Books group and Navigation Books Group (it's a sub category of Books), and also to two Regions groups, USA group and a Canada group. Sometimes the grid may be grouped by both Category and Region, sometimes only one, and other times no grouping.

Right now I am basically creating four different views that contain the information I need for the grid and storing each into a separate ObservableCollection that I can switch to. When the user groups by Category I then switch the itemsource to the ObservableCollection that contains the correct duplicates of the items so that they appear once in each of the corresponding groups.

I'm assuming that the gridview was not built to handle this sort of use case, but is what I'm doing the best way of handling the display of the items. I don't want to have duplicates in the same group at any given time and I haven't been able to come up with a better performing way. The number of unique items in my largest collection can be up to 40,000 items with 18 Properties each, but only 8 columns visible and 2 hidden.

My problem is that creating the collections can be very time consuming and I'm only doing this for 2 grids right now, while in the future I might need to keep a set of collections in memory for up to 8 grids (only 1 would be really big). If one of the original sources of the view is updated I would then have to recreate the ObservableCollection (expensive operation).

Do you have any tips for this kind of gridview usage?

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 15 Jun 2010, 11:16 AM
Hello Francisco Amador,

Generally your approach is the correct one. Since RadGridView does not group the way you require and is not intended to group this way , the solution would be to create the proper View Model as you have done in your case.

If you really need to handle this logic in the UI , rather than in  your View Model, there is still a way .

You may use the hierarchy feature of RadGridView , instead of the grouping feature. You may populate the child grids in  the hierarchy with LINQ queries , to extract the records belonging to a specific "group".
The benefit is the lazy-loading , meaning  no data would be loaded and no query would be executed until the user brings the record into view and expands the child grid.  This approach  may be a bit more effective in terms of memory consumption and performance.

All the best,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Francisco Amador
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or