Currently, the SelectedItems property keep the selecting order for the items selected. For example, if I have a grid with the row A, B, C and D and if I select D, A and C, the SelectedItems propery will contain D, A, and C (in this order, even if it's not how they are displayed).
Is it possible to know the selected items but with the order of how they are in the source ? (so, in my example, it will be A, C, D) ?
I hope to be clear :)
Thanks !
6 Answers, 1 is accepted
Thanks !
You could get the selected items in the order they appear in RadGridView by using the following method :
private
IEnumerable<Object> GetSelectedItems(RadGridView gridView)
{
List<
object
> selectedItems =
new
List<
object
>();
for
(
int
i = 0; i < gridView.Items.Count; i++)
{
if
(gridView.SelectedItems.Contains(gridView.Items[i]))
selectedItems.Add(gridView.Items[i]);
}
return
selectedItems;
}
}
We should probably include this method or a similar one in our public extensions method so that people can use it out of the box.
Best wishes,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have been facing similar kind of issue as mentioned in above post.
Do you have the functionality added in any of new releases of telerik after this?
The order of the items in the SelectedItems collection is by the way they have been selected.
There is not a property to return the selected items ordered in the same way as they are displayed in the GridView.
Didie
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hello,
Any update on this? We would like to get the selected items in the order currently displayed in the grid. I tried the "GetSelectedItems" method above from 12/2009 but the performance is only good when item count is low. With 14K items this loop locks the UI for a few seconds (I imagine from the Contains() method), some of our grids have 90k+ items, so this solution doesn't work for us.
Is there a better way I am missing?
Thank you,
Patrick
At this moment I can't give any other approach which you can use. With the current implementation of the RadGridView, the SelectedItems collection will contain items in the order they are selected.
Regards,
Dinko
Progress Telerik