Sorting Groups -SortMemberPath not being used in group sorting?

4 posts, 0 answers
  1. tsmithtn
    tsmithtn avatar
    8 posts
    Member since:
    May 2007

    Posted 03 Nov 2011 Link to this post

    I have a column whose SortMemberPath is different than the DataMemberBinding.



    <telerik:GridViewDataColumn SortMemberPath="DocumentType" DataMemberBinding="{Binding DocumentTypeId}" IsReadOnly="True" UniqueName="DocTypeIdx" IsVisible="True" IsFilterable="False" /> </telerik:RadGridView.Columns>



    This works as expected when sorting by this column. However, if I drag this column and group by it, the SortMemberPath no longer seems to matter. The grid seems to sort this column by the DataMemberBinding and not SortMemberPath when grouped. Is there a trick to get this to work?

  2. Vera
    Vera avatar
    263 posts

    Posted 04 Nov 2011 Link to this post

    Hi Tony,

    Actually, when RadGridView is grouped and sorted by the same column the sorting is applied to the groups. To get the desired behavior you can use the GroupMemberPath property and set the same value as for the SortMemberPath property.

    Let me know if you need any further assistance.

    Kind regards,
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft R3 2016 release webinar banner
  4. tsmithtn
    tsmithtn avatar
    8 posts
    Member since:
    May 2007

    Posted 04 Nov 2011 Link to this post

    This solution appears to work but it doesnt answer my question completely.  My requirements state that the Document Types must be ordered in a specific way when grouped. (The order is not alphabetical and is defined in the database via a SortOrder property.)  Note in my original example i was sorting by DocumentType only for sake of testing.

    If seems when I set the GroupMemberPath, that now changes the value of my Group.Key.  I have customized the GroupHeaderTemplate. I have it bound to the DocumentTypeId and from there, I use converters to do special rendering:







                 <ColumnDefinition Width="*"/>

                 <ColumnDefinition Width="35"/>


             <TextBlock Text="{Binding Group.Key, Converter={StaticResource docTypeIdToName}}" Grid.Column="0" Style="{StaticResource GridGroupRowStyle}"/>

             <Border Background="{Binding Group.Key, Converter={StaticResource docTypeIdToIndexColor}}" Grid.Column="1" Height="10" BorderBrush="#FFCCCCCC" BorderThickness="1"/>





    So now if I use the GroupMemberPath as below, my Group.Key value now incorrectly has the value for SortOrder and not the DocumentTypeId which I need to do my custom rendering


    <telerik:GridViewDataColumn GroupMemberPath="SortOrder" SortMemberPath="SortOrder" DataMemberBinding="{Binding DocumentTypeId}" IsReadOnly="True" UniqueName="DocTypeId" IsVisible="True" IsFilterable="False" />

    How do I have my group be associated to the DocumentTypeId path but use the SortOrder path for sorting?
    Thoughts? Thanks in advance. 

  5. tsmithtn
    tsmithtn avatar
    8 posts
    Member since:
    May 2007

    Posted 04 Nov 2011 Link to this post

    < snipped.. duplicate>
Back to Top