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

Selecting all rows in a group

1 Answer 289 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nirph
Top achievements
Rank 1
Nirph asked on 28 Feb 2011, 08:19 AM
Hello,

I have a RadGridView bound to a CollectionViewSource. The items in the collection view are sorted by Group Name (e.g "Group 1", "Group 2", etc...).

What is the best way to select all the items (based on group) when a user selects a single row? 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Feb 2011, 02:07 PM
Hi Nirph,

You may handle the SelectionChanged event as follows:

private void playersGrid1_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            var lastItem = e.AddedItems.LastOrDefault() as Player;
             
            if (this.playersGrid1.Items.Groups != null && lastItem != null)
            {
                foreach (IGroup group in this.playersGrid1.Items.Groups)
                {
                    var items = group.Items.Cast<Player>();
                    if (items.Contains(lastItem))
                    {
                        this.playersGrid1.Select(items);
                    }
                }
            }
        }


Best wishes,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Nirph
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or