Selection Changed Event is fired multiple time

2 posts, 0 answers
  1. Vincent
    Vincent avatar
    6 posts
    Member since:
    Oct 2018

    Posted 15 Nov 2018 Link to this post

    Hi ! 

    Every time that I update the query of my gridview, the SelectionChanged event is fired like 10 time in a row.

    On this event, I have a procedure that takes some time so the action is very slow.

    Is there a way to prevent that ? 

    Thank you!

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3958 posts

    Posted 16 Nov 2018 Link to this post

    Hello, Vincent, 

    When the selection in RaGridView is changed, it is expected that the SelectionChanged is fired. If you want to skip the execution of a specific operation that is performed in the SelectionChanged event handler, you can suspend the event and resume it later. Thus, while you are refreshing the grid, the SelectionChanged event won't be fired. You can find below a sample code snippet:

    private void radButton1_Click(object sender, EventArgs e)
    {
        Telerik.WinControls.UI.EventDispatcher dispatcher = this.radGridView1.MasterTemplate.EventDispatcher;
        dispatcher.SuspendEvent(EventDispatcher.SelectionChanging);
        dispatcher.SuspendEvent(EventDispatcher.SelectionChanged);
    }
     
    private void radButton2_Click(object sender, EventArgs e)
    {
        EventDispatcher dispatcher = this.radGridView1.MasterTemplate.EventDispatcher;
        dispatcher.ResumeEvent(EventDispatcher.SelectionChanging);
        dispatcher.ResumeEvent(EventDispatcher.SelectionChanged);
    }

    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top