Cancel Automatic Selection After Row Deleting

4 posts, 1 answers
  1. David
    David avatar
    5 posts
    Member since:
    May 2015

    Posted 22 Jun Link to this post

    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.

  2. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    280 posts

    Posted 23 Jun Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. David
    David avatar
    5 posts
    Member since:
    May 2015

    Posted 28 Jun in reply to Stefan Nenchev Link to this post

    It seems that the default value is not false. Anyway, when I set it explicit to false, it worked for me. Thanks!
  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    280 posts

    Posted 28 Jun Link to this post

    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.
Back to Top