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

Cancel Automatic Selection After Row Deleting

3 Answers 14 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 Jun 2016, 10:43 AM

Hellow,

 

When deleting the selected row in RadGridView, the selection changes automatically to another row. How can I cancel this behaviour ?

There are "Deleted" and "Deleting" events indeed, but they are fired only following a user's deletion. In my case, the deletion is made following a change in the ItemsSource collection.

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 23 Jun 2016, 08:48 AM
Hi David,

Generally, if the IsSynchronizedWithCurrentItem property of RadGridView is set to "False"(this is the default value), deleting the selected item directly from the source collection will leave the control without a selected item. You can try explicitly setting the property to false and check how this works for you.

If you need the property to be true, you can work with the CollectionChanged event of your ItemsSource collection: 

public MainWindow()
       {
           InitializeComponent();
           var collection = (this.clubsGrid.ItemsSource as ObservableCollection<Club>);
           collection.CollectionChanged += collection_CollectionChanged;
       }
 
       void collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
       {
           // work with grid`s selected item
       }


Regards,
Stefan Nenchev
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
David
Top achievements
Rank 1
answered on 28 Jun 2016, 08:28 AM
It seems that the default value is not false. Anyway, when I set it explicit to false, it worked for me. Thanks!
0
Stefan Nenchev
Telerik team
answered on 28 Jun 2016, 12:12 PM
Hi David,

Indeed, the default value is null. Excuse me for the misleading information. I am glad to hear the issue is resolved, though.

Regards,
Stefan Nenchev
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
David
Top achievements
Rank 1
Share this question
or