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

Grouping & CheckBox Control

I am add checkbox to the GrdiGroup Control. I want to change the state of checkbox in grouping. If Group contains 4 record, if i checked 4 records then it should be check group header checkbox and vice versa.

Thank you
Dadasaheb Chobhe


1 Reply

RB Ragamathulla B Syncfusion Team December 5, 2011 07:42 AM UTC

Hi Dadasaheb,

Thank you for your interest in Syncfusio products.

You can change the checkbox status based on the parent table selection by using ‘TableControlCurrentCellChanging’ event. The following code explains the same.

void gridGroupingControl1_TableControlCurrentCellChanging(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
GridStyleInfo style = cc.Renderer.CurrentStyle;

if (cc.Renderer is GridCheckBoxCellRenderer)
{
CultureInfo culture = style.GetCulture(true);
// Load representations for True / False.
string strTrue = "", strFalse = "";
GridCheckBoxCellInfo ua = style.ReadOnlyCheckBoxOptions;
if (ua != null && ua.CheckedValue != null)
strTrue = ua.CheckedValue;
if (GridUtil.IsEmpty(strTrue))
strTrue = "1";
if (ua != null && ua.UncheckedValue != null)
strFalse = ua.UncheckedValue;
if (GridUtil.IsEmpty(strFalse))
strFalse = "0";
// Switch to next value
string strVal = style.Text;
// Checked to unchecked.
if (strVal.ToLower(culture) == strTrue.ToLower(culture))
strVal = strFalse;
// Unchecked to checked.
else
strVal = strTrue;
// Store value.
this.gridGroupingControl1.TableModel[cc.RowIndex, cc.ColIndex].Text = strVal;
this.gridGroupingControl1.Table.Records[0].NestedTables[0].Records[0].SetValue("Status", strVal);
}
}

Please refer to the following sample which illustrates the same.

http://www.syncfusion.com/downloads/Support/DirectTrac/85957/GGCCheckbox-421602947.zip

Please let me know if you have any further concerns.

Regards,
Ragamathullah B.



Loader.
Live Chat Icon For mobile
Up arrow icon