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

Header Checkbox Won't Update

1 Answer 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 30 Apr 2016, 07:35 PM

Hello,

I was unchecking a cell programmatically and was expecting the same behavior as when I uncheck it through the UI, but it seems that the header checkbox is not updated when you modify a cell's value programmatically:

private void RadForm1_Load(object sender, EventArgs e)
{
    radGridView1.AllowSearchRow = true;
    radGridView1.TableElement.SearchHighlightColor = Color.Orange;
    radGridView1.AutoExpandGroups = true;
 
    DataTable dt = new DataTable();
 
    dt.Columns.Add("test", typeof(bool));
 
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
    dt.Rows.Add(true);
 
    radGridView1.DataSource = dt;
 
    ((Telerik.WinControls.UI.GridViewCheckBoxColumn)radGridView1.Columns[0]).EnableHeaderCheckBox = true;
    ((Telerik.WinControls.UI.GridViewCheckBoxColumn)radGridView1.Columns[0]).Width = radGridView1.Width - 50;
 
    radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset); //force header checkbox to check
 
    radGridView1.TableElement.ScrollTo(15, 0);
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.Rows[0].Cells[0].Value = false;
}

I have tried adding radGridView1.TableElement.BeginUpdate() to the beginning & radGridView1.TableElement.EndUpdate() to the end of radButton1_Click, along with radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.ExpandedChanged) & radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset) immediately after changing the cell's value, but all of these lines seem to invalidate the RadGridView in one way or another. They cause the search row's buttons to flicker and scroll the RadGridView up to the top.

Is there a solution to this problem that will result in behavior similar to checking/unchecking a cell using the UI?

Thank you!

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 02 May 2016, 12:14 PM
Hi Ryan,

Thank you for writing.

I was able to reprduce the observed issue. I have logged it in our Feedback Portal. You can track the item for status changes and add your vote for it here.

To workaround this you can manually update the cell with the line of code that you are alredy using:
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.Rows[0].Cells[0].Value = false;
    radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset);
}

Your Telerik Points have been updated for this report.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
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
Ryan
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or