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

Sorting/Grouping on a Dictionary<string, object>

3 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sunil
Top achievements
Rank 1
Sunil asked on 19 Jul 2012, 05:27 PM
Hi Guys,

I have a GridView whose ItemsSource is bound to a collection of say ObjectX.

ObjectX has a Dictionary<string, object> in it where I am storing some context data.
I define the columns in xaml like so:

<telerik:GridViewDataColumn Header="Col1" DataMemberBinding="{Binding Path=Context[key1]}"
<telerik:GridViewDataColumn Header="Col2" DataMemberBinding="{Binding Path=Context[key2]}" />
<telerik:GridViewDataColumn Header="Col3" DataMemberBinding="{Binding Path=Context[key3]}" />

Where Context is the Dictionary collection. This works great (I am able to display the correct data). But I cannot do any grouping/sorting/filtering on these columns. I have tried setting the GroupMemberPath and SortMemberPath with no luck.
What am I missing? 

Any help would be greatly appreciated.

Regards

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Jul 2012, 05:55 AM
Hi,

 I would suggest you to check this forum thread where a similar topic is discussed.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Sunil
Top achievements
Rank 1
answered on 20 Jul 2012, 02:53 PM
Thanks for the response!

I don't think this will work because I also need to display columns that ARE NOT part of the Dictionary. For example:

public class ObjectX
{
	public string Name { get; set; }
		
	public Dictionary<string, object> Context { get; set; }
} In the grid, I would like to display my "known" columns (Name) plus my dynamic columns (the Dictionary). So the ItemsSource of the grid is ObservableCollection<ObjectX>. Like I said before, I can display the information correctly, but I cannot perform grouping or sorting in the dynamic columns.

Any other ideas?
0
Dimitrina
Telerik team
answered on 24 Jul 2012, 09:25 AM
Hi,

If you have some static columns, then you could define them initially when defining the RadGridView. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Sunil
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Sunil
Top achievements
Rank 1
Share this question
or