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

REQUEST: Selectable Groupings

6 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jie
Top achievements
Rank 1
Jie asked on 09 Jun 2009, 09:12 PM
I would like to be able to select all items within a Grouping by just clicking the Group header (or a button in the Group Header)

An alternative would be an event that fires after the user clicks on the Group header, and then within the event handler, iterate through items in that group and programmatically select them.  I've looked but couldn't find an event like this.  Does anything event on the RadGridView catch the click on the Group Header?

I've looked through this forum for this request or someone talking about this topic, but haven't found any.  Sorry, if this is repeat request.

6 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 10 Jun 2009, 03:05 PM
Hi Jie,

I have prepared a small sample for you . Please have a look at the attached project .

Let me know if you have any troubles adapting this to your project.

Best wishes,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jie
Top achievements
Rank 1
answered on 10 Jun 2009, 08:51 PM

Pavel, excellent, thanks!

This is the code I added to your solution to select the records within the group.

 

 

private void PART_GroupExpander_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

 

{

    // Unselect previously selected records

    // ui_RadGridView.UnselectAll();  <--- Doesn't work
    
    GroupRecord
groupRecord = (GroupRecord)((GridViewExpander)sender).DataContext;

 

 

    foreach (DataRecord record in groupRecord.Records.OfType<DataRecord>())

 

        record.IsSelected =

true;

 

}

At this point, it only adds these records to the SelectedRecords collection, but doesn't remove the previously selected items, which I would like it to do.  As described above, I tried to do call an UnselectAll() on the GridView control before selecting these items, but I guess because of the asynchronous nature of the control, the unselection happens AFTER the grouped records are selected, thus wiping out the correctly selected items.

Anyway around this?

0
Pavel Pavlov
Telerik team
answered on 16 Jun 2009, 08:54 AM
Hi Jie,

I have touched the sample a little bit . I have added a Multiselect="true" attribute to the RadGridvView.
And I have placed your code. All now seems to work fine . Please have a look at the attachment.


Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jamest
Top achievements
Rank 2
answered on 20 Oct 2009, 08:37 PM
I know this is an older thread but would like an example using the updated API. Now that GroupRecords and such are deprecated/obsolete. Thank you.
0
Pavel Pavlov
Telerik team
answered on 22 Oct 2009, 03:16 PM
Hello Ender,

Please have a look at the attached project . It demonstrates  how to use the new API to achieve the desired behavior.
I apologize it is not Silverlight but WPF project. However as you know our controls share a common codebase and I believe the code may also run under Silverlight with almost no changes.
In case you need assistance making this work in Silverlight just drop me a line.

All the best,
Pavel Pavlov
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
Jamest
Top achievements
Rank 2
answered on 22 Oct 2009, 10:21 PM
Pavel Pavlov,
  Thank you for your example. It provided enough for me to get what I needed. In the end it was pretty simple, I didn't realize there was a group header template in the api and that in the end all I needed to do was add the items myself to the SelectedItems collection rather than trying to obtain a gridviewrow that doesn't exist for all of the items. (I wanted them highlighted so they can be immediately dragged and dropped).  My thinking was backwards to the heavy grids that rendered every row even though not needed. I appreciate your time.
      Cheers,
            Jordan
Tags
GridView
Asked by
Jie
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jie
Top achievements
Rank 1
Jamest
Top achievements
Rank 2
Share this question
or