We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

checkBox in Grid event handler

I have checkboxes in a gridgroupingcontrol.

I hook into the TableControlCheckBoxClick event.

within this event, I capture the checked state of the checkbox and update the backend server with the new state, now if the server update fails, i want to revert the checkbox to its original checkstate before returning from this event, how do i go about this.

2 Replies

HA haneefm Syncfusion Team June 6, 2007 06:33 PM UTC

Hi Nedu,

The TableControlCheckBoxClick is the event that gets triggered only when user clicks using the mouse on the checker box of checkbox cell. You can catch the TableControlCurrentCellChanged event for detecting any changes made to the checkbox cell. If the update fails, then you can set cell value using the CurrentRecord.SetValue method in a grid. Below is a code snippet

void grid_TableControlCurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "CheckBox")
{
Console.WriteLine("CheckBox cell( {0},{1})=> {2}", cc.RowIndex, cc.ColIndex, e.TableControl.GetTableViewStyleInfo(cc.RowIndex,cc.ColIndex).CellValue );
if( updateFails )
{
e.TableControl.Table.CurrentRecord.SetValue("CheckBox",false);
e.TableControl.Table.CurrentRecord.EndEdit();
}
}
}

Best regards,
Haneef


CH Chinedu June 6, 2007 08:25 PM UTC

Thanks Haneef,

How do I get the original checkstate of the checkbox, if the server update fails, I want to stop the change from going thru.

For instance, lets say the checkbox has a value of [True or Checked], a user clicks on it to change it to [False or UnChecked], I capture that click event and update the server with the new value, which would be [False or UnChecked] now and all is fine

However, if the update to the server fails, I want to keep the original value of the checkbox which is [True or Checked] in this case...

Loader.
Live Chat Icon For mobile
Up arrow icon