GroupDescriptor: dealing with null values and sorting

3 posts, 0 answers
  1. Matt Greer
    Matt Greer avatar
    30 posts
    Member since:
    May 2010

    Posted 13 Jul 2010 Link to this post

    I have my RadGridView grouping by using a GroupDescriptor, like this: 

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

    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.

  2. Tsvyatko
    Tsvyatko avatar
    863 posts

    Posted 19 Jul 2010 Link to this post

    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,
    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
  3. De
    De avatar
    4 posts
    Member since:
    Feb 2011

    Posted 19 Sep 2011 Link to this post

    The suggestion still seems hacky though.  Is there a way to group using 1 property and sort the groups using another property?
Back to Top