Sunday 13 April 2014


Share/Bookmark
Issue: 

How to Sort RadGridView in ascending order based on a column value when it is loaded.


How did I fix it: 

Use SortDescriptors to Sort RadGridView in ascending order based on a column value when it is loaded. Sort descriptors can be used as shown below.
Here the list bind to RadGridView is list of Signals. Structure of Signal is as shown below.

struct Signal
    {
        public int Id { get; set; }

        public string Name { get; set; }
    }

Here we are trying to sort the list displayed based in the Id in ascending order.

<telerik:RadGridView ItemsSource="{Binding Events}">
<telerik:RadGridView.SortDescriptors>
    <telerik:SortDescriptor Member="Timestamp" SortDirection="Descending" />
    </telerik:RadGridView.SortDescriptors>
<telerik:RadGridView.Columns>
   <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="ID" />
 <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Categories:

0 comments:

Post a Comment

Dear reader, Your comment is always appreciated. I will reply to your queries as soon as possible.

1. Make sure to click on the Subscribe By Email link to be notified of follow up comments and replies. Or you can use Subscribe to: Post Comments (Atom) link.
2. Only English comments shall be approved.
3. Please make your comments self-explanatory. Comment in such a way that it explains the comment so that a counter question can be avoided and can be replied with proper answer on the first go.