I have a grid that I want to sort by "Sequence" property by default.
However, this should not be visible to user.
<control:RadGridView ="grid" >
<control:RadGridView.SortDescriptors>
<telerik:SortDescriptor Member="Sequence" SortDirection="Ascending" />
</control:RadGridView.SortDescriptors>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Sequence" DataMemberBinding="{Binding Sequence}" IsReadOnly="True" IsVisible="False"/>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}"/>
...
User should only see the "Name" column while sorted by sequence.
Apparently, the sort only works when the sequence column IsVisible=True
Is it possible to hide it and sort as the same time?
Thanks,
Clarian
8 Answers, 1 is accepted
In order to have the column being Sorted on Sequence values, you should provide a valid sort path for it ( SortMemberPath="Sequence").
Kind regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Should I add it to the Name column? (With that I can remove the Sequence column?)
What should my code above be?
<control:RadGridView ="grid" >
<control:RadGridView.SortDescriptors>
<telerik:SortDescriptor Member="Name" SortDirection="Ascending" />
</control:RadGridView.SortDescriptors>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" SortMemberPath="Sequence"/>
Thank you for the update. This code will do sorting based on the Name values. If you want to sort on the Sequence values, you have to set Member="Sequence". That way you will not have a Sorting Indicator on the GridViewHeaderCell though.
To have the indicator, you should use a ColumnSortDescriptor instead:
<
telerik:RadGridView.SortDescriptors
>
<
telerik:ColumnSortDescriptor
Column
=
"{Binding Columns[\Name\], ElementName=clubsGrid}"
SortDirection
=
"Ascending"
/>
</
telerik:RadGridView.SortDescriptors
>
I hope this helps.
Kind regards,
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi -- How can I do this programatically/dynamically, such that the Sorting Indicator will be hidden?
_nameSort = new ColumnSortDescriptor()
{
Column = this.grid.Columns["Name"],
SortDirection = System.ComponentModel.ListSortDirection.Ascending
};
this.grid.SortDescriptors.Add(_nameSort); Thanks!
You could set the SortingState of the Column to be None. For example:
_nameSort.Column.SortingState = SortingState.None;
Didie
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
You should add this line after you have added the descriptor to the SortDesriptors collection.
Regards,Didie
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.