EnableHeaderCheckBox to check only enabled check boxes

2 posts, 0 answers
  1. Jean-Bernard
    Jean-Bernard avatar
    1 posts
    Member since:
    Aug 2020

    Posted 10 Aug 2020 Link to this post

    My grid has a checkbox column "MyColumn" that has EnableHeaderCheckBox enabled.  That column is disabled in the following manner using the CellFormatting event, code follows(did it this way due to need to show a tool tip).  When I click on the header check box, every check box, including the disabled ones, are checked.  I don't want those that are disabled to be checked.  I've tried using the event HeaderCellToggleStateChanged to modify the toggle value of the checkbox, it's not taking effect.  How can I do this?


     private void MyGrid_CellFormatting(object sender, CellFormattingEventArgs e)

                    e.CellElement.RowElement.ToolTipText = @"";
                    e.CellElement.Enabled = true;

                if (!(bool)e.Row.Cells["Condition1"].Value)
                        e.CellElement.Enabled = false;
                        e.CellElement.RowElement.ToolTipText = @"Disabled condition 1 ";


  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4166 posts

    Posted 11 Aug 2020 Link to this post

    Hello, Jean-Bernard,

    If I understand your requirement correctly, you want to toggle only the check boxes belonging to cell elements that are not disabled. This custom behavior has to be achieved programmatically. 

    Please have in mind that GridViewCheckBoxColumn offers the ShouldCheckDataRows property which determines whether the CheckBox in the header cell will be synced with the data cells. When true, the header check box will check the data cells and vice versa. It seems that for your scenario it would be more suitable to set this property to false and manage programmatically the checked value only for the data cells that you want. In other words, you will need to iterate the RadGridView.Rows collection and update the cells values to the desired rows.

    It is important to note that if you have many rows in the grid, it would be good to wrap this code block of iterating the rows and managing the values in a RadGridView.BeginUpdate/ RadGridView.EndUpdate block. Thus, you will not refresh the grid which every value change.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Dess | Tech Support Engineer, Sr.
    Progress Telerik

Back to Top