Unplanned
Last Updated: 19 May 2020 14:02 by ADMIN
Michael
Created on: 19 May 2020 10:37
Category: GridView
Type: Feature Request
1
RadGridView: provide opportunity to cancel the toggle state change on GridCheckBoxHeaderCellElement

Hello.

In my application, depending on the specific data in the grid I may want to warn a user who clicks on the header checkbox that changing all the values in that column may not be what he intends, allowing him to cancel out of the operation.  I haven't found a handler that gets called when clicking on the header checkbox that allows me to cancel the event.  How can I accomplish this?

1 comment
ADMIN
Nadya
Posted on: 19 May 2020 14:02

Hello Michael,

RadGridView offers the HeaderCellToggleStateChanged event that fires when the RadCheckedBoxElement in the header cell has already been changed. However, it seems to be a reasonable request to allow users to prevent the operation under some circumstances.

This is why I have logged it as a feature request on our Feedback portal by making this thread public. You can vote for it, subscribe to status changes, and add your comment to it here. The more votes an item gathers, the higher its priority becomes.

I have also updated your Telerik Points.

Currently, the possible solution that I can suggest is to access the checkbox within the GridCheckBoxHeaderCellElement and handle its ToggleStateChanging that can be canceled:

private void RadGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
    if (sender is GridCheckBoxHeaderCellElement)
    {
        GridCheckBoxHeaderCellElement cell = sender as GridCheckBoxHeaderCellElement;
        cell.CheckBox.ToggleStateChanging -= this.CheckBox_ToggleStateChanging;
        cell.CheckBox.ToggleStateChanging += this.CheckBox_ToggleStateChanging;
    } 
}

private void CheckBox_ToggleStateChanging(object sender, StateChangingEventArgs args)
{
    args.Cancel = true;
}

I hope this helps. Should you have other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.