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

Event for Checkbox click.

Hi,

I am using syncfusion grid grouping control. I want to capture check box event control so that I can modify the current record's property depending on check box's boolen value.

For Eg. I have check boxes in one column for each row.
If I check one check box for particular row, then I want to modify the current record's property.
Here I also want to get current record's data.

Please help.

Thanks,
Amol Choudhari

5 Replies

HA haneefm Syncfusion Team July 24, 2007 02:43 PM UTC

Hi Amol,

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. Below is a code snippet:

void gridTableControlCurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "CheckBox")
{
Console.WrtieLine( e.TableControl.Table.CurrentRecord.Info);
DataRowview rv = e.TableControl.Table.CurrentRecord.GetData() as DataRowview;
}
}

gridGroupingControl1.TableControlCheckBoxClick += new Grouping.GridTableControlCellClickEventHandler(gridTableControlCheckBoxClick);

void gridTableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WrtieLine( e.TableControl.Table.CurrentRecord.Info);
DataRowview rv = e.TableControl.Table.CurrentRecord.GetData() as DataRowview;
}

Best regards,
Haneef


AC Amol Choudhari July 24, 2007 03:42 PM UTC

Hi Haneef,

In my case TableControlCurrentCellChanged event is not fired while clicking on check box on particular row. So this event is not useful I hope...

and TableControlCheckBoxClick event is fired in my grid, while clicking on check box but
in this case I am not getting CURRENTRECORD.
at (e.TableControl.Table.CurrentRecord.GetData() - here CurrentRecord is null )
So not able to modify the property of selected row's data.

Please suggest any other way.

Thanks,
Amol Choudhari

>Hi Amol,

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. Below is a code snippet:

void gridTableControlCurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "CheckBox")
{
Console.WrtieLine( e.TableControl.Table.CurrentRecord.Info);
DataRowview rv = e.TableControl.Table.CurrentRecord.GetData() as DataRowview;
}
}

gridGroupingControl1.TableControlCheckBoxClick += new Grouping.GridTableControlCellClickEventHandler(gridTableControlCheckBoxClick);

void gridTableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WrtieLine( e.TableControl.Table.CurrentRecord.Info);
DataRowview rv = e.TableControl.Table.CurrentRecord.GetData() as DataRowview;
}

Best regards,
Haneef


HA haneefm Syncfusion Team July 24, 2007 10:27 PM UTC

Hi Amol,

You can try these code :

private void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
int RowIndex = e.Inner.RowIndex;
int ColIndex = e.Inner.ColIndex;
if( RowIndex > -1 && ColIndex > -1)
{
GridTableCellStyleInfo Style = e.TableControl.GetTableViewStyleInfo(RowIndex, ColIndex);
if( Style != null)
{
Element el = Style.TableCellIdentity.DisplayElement;
if (el != null)
{
Record rec = el.GetRecord();
DataRowView dv = rec.GetData() as DataRowView;
}
}
}
}

Best regards,
Haneef


GU Guadalupe March 27, 2019 06:41 PM UTC

Hello Amount
This code is correct? 


VN Vignesh Natarajan Syncfusion Team March 29, 2019 11:26 AM UTC

Hi Gaudalupe, 

Thanks for contacting Syncfusion support. 

The solution given in the previous updates of this forum is applicable in GridGroupingControl which is an ASP.NET Classic component,but you are using the Essential JS1 (ASP.NET WebForms) component. So, the same cannot be achieved in the Syncfusion Essential JS 1 Asp.Net Webforms. 

So kindly share the exact scenario and details regarding your requirement. We will provide the appropriate solution for your requirement. 

Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon