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

GroupDescriptor: dealing with null values and sorting

2 Answers 294 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matt Greer
Top achievements
Rank 1
Matt Greer asked on 14 Jul 2010, 12:35 AM
I have my RadGridView grouping by using a GroupDescriptor, like this: 

<gridView:RadGridView x:Name="_businessRequirementsByCategory"
              ItemsSource="{Binding BusinessRequirements}"
              Style="{StaticResource _gridStyle}">
         
        <gridView:RadGridView.Columns>
            <gridView:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
            <gridView:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description}" />
        </gridView:RadGridView.Columns>
 
            <gridView:RadGridView.GroupDescriptors>
                <telerikData:GroupDescriptor DisplayContent="Category" Member="Category" SortDirection="Ascending" />
        </gridView:RadGridView.GroupDescriptors>
</gridView:RadGridView>


I want to do two things:
Have the group header display a default value such as "<Missing>" or "<Unassigned>" for any objects in my grid that have their Category being null. Is there a well defined way to do this? The way I have it now is to add another property to my object called CategoryName and have it return "<Unassigned>" in the case that Category is null. Then group on that property instead.

I also want to push the "<Unassigned>" group to the bottom of the grid. The grid is placing this group first, I suppose because the sorting algorithm being used is considering '<' comes before 'a'. I really don't want to do anything hacky like make this category's name start with a 'z' or something like that. Is there anyway I can control the ordering of the groups in the grid?

And btw, what does the GroupDescriptor.DisplayContent property do? As far as I can tell, it doesn't do anything.


Thanks.

2 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 19 Jul 2010, 01:41 PM
Hi Matt Greer,

Using additional property is good choice in your scenario. I have recommend one additional option - using converter for altering the display value for the group header. (demonstrated in the attachment).

About the sort order, you can define sort direction for the current group descriptor using its SortDirection property.

In addition if you do not want use sort direction but only moving the null values at the bottom, I can suggest you to combine custom property approach with using the converter - the property value will affect the position of the group while converter will take care of the display value.


Best wishes,
Tsvyatko
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
0
De
Top achievements
Rank 1
answered on 19 Sep 2011, 10:59 PM
The suggestion still seems hacky though.  Is there a way to group using 1 property and sort the groups using another property?
Tags
GridView
Asked by
Matt Greer
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
De
Top achievements
Rank 1
Share this question
or