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

How to prevent SelectedItems to keep selecting order ?

6 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas LEBRUN
Top achievements
Rank 1
Thomas LEBRUN asked on 03 Dec 2009, 12:08 PM
Hi,

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

Sort by
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 04 Dec 2009, 06:07 AM
Any ideas ?


Thanks !
0
Milan
Telerik team
answered on 04 Dec 2009, 07:12 AM
Hello Thomas LEBRUN,

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.
0
Pankaj
Top achievements
Rank 1
answered on 25 Oct 2013, 10:27 AM
Hi,

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?
0
Dimitrina
Telerik team
answered on 29 Oct 2013, 02:19 PM
Hello,

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.
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
0
Patrick
Top achievements
Rank 1
answered on 15 Mar 2018, 07:55 PM

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

0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Mar 2018, 01:34 PM
Hello 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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Thomas LEBRUN
Top achievements
Rank 1
Answers by
Thomas LEBRUN
Top achievements
Rank 1
Milan
Telerik team
Pankaj
Top achievements
Rank 1
Dimitrina
Telerik team
Patrick
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or