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

Anyone knows how to set the default sorted column?

5 Answers 349 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yang Lu
Top achievements
Rank 1
Yang Lu asked on 16 Jun 2010, 09:09 PM
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

5 Answers, 1 is accepted

Sort by
0
Ваня
Top achievements
Rank 1
answered on 16 Jun 2010, 09:31 PM
                               datagridView.Sort(datagridView.Columns[1], ListSortDirection.Ascending);  
                               datagridView.Columns[1] is example the "Name" column
0
Yang Lu
Top achievements
Rank 1
answered on 16 Jun 2010, 09:40 PM
Thank you Vanya! I meant to ask whether there is a way to do it in xaml?
0
Ваня
Top achievements
Rank 1
answered on 17 Jun 2010, 05:10 AM
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...
0
Accepted
Vlad
Telerik team
answered on 17 Jun 2010, 06:22 AM
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.
0
Yang Lu
Top achievements
Rank 1
answered on 17 Jun 2010, 06:36 AM
Thank you Vlad! It worked perfectly.

~Yang
Tags
GridView
Asked by
Yang Lu
Top achievements
Rank 1
Answers by
Ваня
Top achievements
Rank 1
Yang Lu
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or