How to prevent SelectedItems to keep selecting order ?

5 posts, 0 answers
  1. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 03 Dec 2009 Link to this post

    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 !
  2. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 04 Dec 2009 Link to this post

    Any ideas ?


    Thanks !
  3. DevCraft banner
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 04 Dec 2009 Link to this post

    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.
  5. Pankaj
    Pankaj avatar
    2 posts
    Member since:
    Jan 2013

    Posted 25 Oct 2013 Link to this post

    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?
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Oct 2013 Link to this post

    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 >>
Back to Top
DevCraft banner