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

RadGridView CollectionChanged Event

4 Answers 621 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nirav
Top achievements
Rank 1
Nirav asked on 02 Nov 2015, 06:48 AM

Hi,

Our code is using WPF with MVVM pattern. We are using the RadGridView to display the users data in rows with check box option to select/deselect all rows.

In my code I have a class which derives from 

Behavior<RadGridView>

and inside I have 

target.AssociatedObject.SelectedItems.CollectionChanged += target.GridSelectedItems_CollectionChanged;
where target is ​Behavior<RadGridView>

My WPF code related to grid is: 

<telerik:RadGridView x:Name="Users" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ShowColumnFooters="True"  SelectionMode="Extended"><telerik:RadGridView x:Name="Users"Stretch" AutoGenerateColumns="False" ShowColumnFooters="True" SelectionMode="Extended">​

Issue:

When I select all using the top most checkbox in the grid - the event 

GridSelectedItems_CollectionChanged

fires for every item getting selected. So, if grid have 5 users in the grid - the event fires 5 times for selection/deselection of contacts.

 I think collection changed method should fire only one time.

 

Any clarification on this would be appreciated.

Thanks,

Nirav Patel

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 04 Nov 2015, 04:03 PM
Hi Nirav,

The recommended approach for such scenarios is to use the SelectionChanged event of RadGridView. Would it be possible for you to share some details on what you are trying to achieve? Is there a specific requirement to handle the CollectionChanged event of the SelectedItems collection, instead of SelectionChanged?

Best Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Nirav
Top achievements
Rank 1
answered on 10 Nov 2015, 01:00 AM

Thanks Stefan for the reply. My apologies for the late reply.

 I am using the code mentioned in the blog http://www.telerik.com/blogs/how-to-synchronize-your-ui-selected-items-with-your-data-context-using-mvvm-and-blend-behaviors-for-silverlight-and-wpf

It has the SelectedItems.CollectionChanged in it.
0
Stefan
Telerik team
answered on 11 Nov 2015, 04:19 PM
Hello Nirav,

Thank you for this clarification.

However, for a scenario as yours in which you depend on the selection, as suggested in my previous post, I recommend you using the SelectionChanged event of the control.

Regards,
Stefan X1
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Nirav
Top achievements
Rank 1
answered on 11 Nov 2015, 11:15 PM
Thanks Stefan for the update. I'll implement as suggested.
Tags
GridView
Asked by
Nirav
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Nirav
Top achievements
Rank 1
Share this question
or