Initial sorting in a grid

2 posts, 0 answers
  1. rubenhak
    rubenhak avatar
    58 posts
    Member since:
    Dec 2008

    Posted 16 Aug 2010 Link to this post

    Hi,

    Is it possible to make the grid to be sorted initially? 
    I'd prefer a declarative way to do it (in XAML).

    Can you guys provide an example of a grid which is initially sorted by some column.

    Thank you very much,
    Ruben
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Aug 2010 Link to this post

    Hello rubenhak,

    There is no problem to do that in XAML - just create a SortDescriptor like this:

    <telerik:RadGridView Name="playersGrid" 
                         ItemsSource="{Binding Players}" 
                         AutoGenerateColumns="False">
        <telerik:RadGridView.SortDescriptors>
            <!-- define initial sorting by name-->
            <telerik:SortDescriptor Member="Name"/>
        </telerik:RadGridView.SortDescriptors>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>


    Best wishes,
    Milan
    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. UI for WPF is Visual Studio 2017 Ready
Back to Top