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

[Solved] Respecting Items Sort Order

1 Answer 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 1
Bill asked on 19 Jan 2011, 03:23 PM
Hello,

I have a RadGridView in my Silverlight application. A user may sort the items in the RadGridView. When a user clicks a button in my application, I want to cycle through the items in the RadGridView. My problem is, I want to cycle through them in the order that they are sorted by. In an attempt to do this, I decided to get the sort information like so:

var items = myGridView.ItemsSource; 
 
// Attempt to sort RadGridView.ItemsSource for usage
string sorters = string.Empty;
foreach (ISortDescriptor descriptor in myGridView.SortDescriptors)
{
  if (descriptor is ColumnSortDescriptor)
  {
    if (sorters .Length > 0)
      sorters += ", ";
 
    ColumnSortDescriptor sortDescriptor = (ColumnSortDescriptor)(descriptor);
    sorters += sortDescriptor.Column.SortMemberPath;
  }
}           

From here, I'm stuck though. Am I making this too hard? Its seems like there should be an easy way to get the items in their sorted order from the RadGridView. Can someone please help me solve this problem?

Thank you very much for your help!

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 19 Jan 2011, 03:47 PM
Hi Bill,

You should iterate the Items collection of the RadGridView - it will contain the sorted data.

All the best,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Bill
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or