Anyone knows how to set the default sorted column?

6 posts, 1 answers
  1. Yang Lu
    Yang Lu avatar
    5 posts
    Member since:
    May 2010

    Posted 16 Jun 2010 Link to this post

    I have my data shown correctly in the gridview. Now I want to have them sorted by "Name" by default. How could I do that?

    Thanks,
    Yang
  2. vanya
    vanya avatar
    35 posts
    Member since:
    Nov 2008

    Posted 16 Jun 2010 Link to this post

                                   datagridView.Sort(datagridView.Columns[1], ListSortDirection.Ascending);  
                                   datagridView.Columns[1] is example the "Name" column
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yang Lu
    Yang Lu avatar
    5 posts
    Member since:
    May 2010

    Posted 16 Jun 2010 Link to this post

    Thank you Vanya! I meant to ask whether there is a way to do it in xaml?
  5. vanya
    vanya avatar
    35 posts
    Member since:
    Nov 2008

    Posted 17 Jun 2010 Link to this post

    Check this out for that option:
    http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ae5f1426-7651-4197-b8d3-9a4c94c02354
    You an see an example in this thread using CollectionViewSource...
  6. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Jun 2010 Link to this post

    Hello,

     You can achieve your goal if you declare desired SortDescriptor in XAML similar to the GroupDescriptor in this demo.

    Kind regards,
    Vlad
    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.
  7. Yang Lu
    Yang Lu avatar
    5 posts
    Member since:
    May 2010

    Posted 17 Jun 2010 Link to this post

    Thank you Vlad! It worked perfectly.

    ~Yang
Back to Top
UI for WPF is Visual Studio 2017 Ready