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

Sorting Groups -SortMemberPath not being used in group sorting?

3 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
tsmithtn
Top achievements
Rank 1
tsmithtn asked on 03 Nov 2011, 06:04 PM

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

<telerik:RadGridView.Columns>

 

<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?

3 Answers, 1 is accepted

Sort by
0
Vera
Telerik team
answered on 04 Nov 2011, 11:18 AM
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,
Vera
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
tsmithtn
Top achievements
Rank 1
answered on 04 Nov 2011, 04:14 PM

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:

 

 

<telerik:RadGridView.GroupHeaderTemplate>

     <DataTemplate>

    <Grid>

        <Grid.ColumnDefinitions>

             <ColumnDefinition Width="*"/>

             <ColumnDefinition Width="35"/>

         </Grid.ColumnDefinitions>

         <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"/>

     </Grid>

     </DataTemplate>

</telerik:RadGridView.GroupHeaderTemplate>

 

 
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. 


0
tsmithtn
Top achievements
Rank 1
answered on 04 Nov 2011, 04:15 PM
< snipped.. duplicate>
Tags
GridView
Asked by
tsmithtn
Top achievements
Rank 1
Answers by
Vera
Telerik team
tsmithtn
Top achievements
Rank 1
Share this question
or