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

TableControlCheckBoxClick and preventing specific rows from being ''checkable''

I have a checkbox in the first column (header and records).

How do I prevent specific rows from being checkable.

For example, when the user attempts to check row 3, I want to prevent that row from being check if the 'Status' of that row record is set to 'inactive', for example. Likewise, I want to skip over this row when the user check the header to checks all the records in the grid.

I know that I can do it from the TableControlCheckBoxClick event via e.Inner.Cancel = true, but I am not sure if style.TableCellIdentity.RowIndex directly maps to the row index of the underlying datasource, given the fact that the grid is sortable, ect..

1 Reply

AD Administrator Syncfusion Team January 3, 2007 10:06 PM UTC

Hi James,

Thank you for being patience.

The idea to skip and disable the checkbox whose row is inactive is by handling the QueryCellStyleInfo event and set the corresponding checkbox to be disabled.

For example, in the following code snippet the column 'Col2' decides the row being inactive or active
>>>>>>>>>>>>>>>Code Snippet<<<<<<<<<<<<<<<<<<<
private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if(e.TableCellIdentity.Column.Name.Equals("Col0"))
{
Element el = e.TableCellIdentity.DisplayElement;
if(el != null && el.Kind == DisplayElementKind.Record)
{
Record r = el.GetRecord();
string key;
if (r != null && r.GetValue("Col2") != null)
{
key = r.GetValue("Col2").ToString();
if(key.Equals("inactive"))
{
e.Style.CellValue = false;
e.Style.Enabled = false;
e.Handled = true;
}
}
}
}
}
}
>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<

Sample: GGC_CheckBoxIssue.zip

The following KB article demonstrates the technique to have check box in header cell
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=346

Please try the above the code snippet and let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


Loader.
Live Chat Icon For mobile
Up arrow icon