We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Notification on SelectRows()

Hi,

I was wondering if SfDataGrid.SelectionChanged whould also be called when programatically selecting rows with SelectRows(r1, r2)?

Actually it does not trigger the notification. IS this a bug or am I doing something wrong?

Regards
Bernd

3 Replies

JG Jai Ganesh S Syncfusion Team December 8, 2016 02:12 PM UTC

Hi Bernd, 
We regret to inform you that, the SelectionChanged event will not be fired while we select the rows programmatically. This is the default behavior of SfDataGrid. However, you can get the notification while calling the SelectRows by using SelectedItems.CollectionChanged event like below, 
 this.datagrid.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; 
 
 private void SelectedItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 
        { 
            var selectedItem = e.NewItems[0]; 
        } 
 
Regards, 
Jai Ganesh S 



BE Bernd December 9, 2016 10:54 AM UTC

Hi Jai,

thank you for pointing out a direction. I have to see how I can make use of this because I do modifiy SelectedItems within my handler and this could lead to an infinite recursion so I could either disable/reenable the nofitication while processing it or I have to rewrite my code.

The reason I am modifing SelectedItems is because I want to support selection of groups (both collapsed and expanded) with automatically including all contained subgroups or items.

However, you can consider this issue as resolved.

Regards
Bernd


GM Gobikrishnan Murugesan Syncfusion Team December 12, 2016 04:58 AM UTC

Hi Bernd,  
 
Thank you for the update.  
 
Please let us know if you need further assistance on this.  
 
Regards,  
Gobikrishnan 


Loader.
Live Chat Icon For mobile
Up arrow icon