Problem with check box columns in nested entities
I am using GGC and using nested entities to bound the data.
Following snippets will give you an idea how i am designing the grid for parent and child entities. Note that for boolan data, i want to display check boxes.
// adding partent data
private void AddParentBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}
}
// adding child data
private void AddChildBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}
}
Every thing is working fine except for TableControlCurrentCellChanged event.
For the child data, I am able to hit this event when i click on a check box for child data. But this is not happeing for when i check a cell at the parent level.
Please advice.
Just to add to this, if i comment the code as shown below for parent columns , it shows dropdowns instead of checkboxes, which is not desired. But in that case when i change the value in drop down the event does get fired.
private void AddParentBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
// if (pd != null &&
// pd.PropertyType.Equals(typeof(bool)))
// {
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
// }
}
Following snippets will give you an idea how i am designing the grid for parent and child entities. Note that for boolan data, i want to display check boxes.
// adding partent data
private void AddParentBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}
}
// adding child data
private void AddChildBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}
}
Every thing is working fine except for TableControlCurrentCellChanged event.
For the child data, I am able to hit this event when i click on a check box for child data. But this is not happeing for when i check a cell at the parent level.
Please advice.
Just to add to this, if i comment the code as shown below for parent columns , it shows dropdowns instead of checkboxes, which is not desired. But in that case when i change the value in drop down the event does get fired.
private void AddParentBoundColumn(string columnName, string toolTipText)
{
dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;
PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);
// if (pd != null &&
// pd.PropertyType.Equals(typeof(bool)))
// {
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
// }
}
SIGN IN To post a reply.
3 Replies
HA
haneefm
Syncfusion Team
July 25, 2007 11:08 PM UTC
Hi Dinesh,
At runtime, you can set celltype of the child table column using below code:
GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}
Best regards,
Haneef
At runtime, you can set celltype of the child table column using below code:
GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}
Best regards,
Haneef
DU
dinesh upreti
July 26, 2007 09:03 AM UTC
hi,
the problem with TableControlCheckBoxClick
event is that it doesnt get fired if the user checks a checkbox using space bar.
Thanks
>Hi Dinesh,
At runtime, you can set celltype of the child table column using below code:
GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}
Best regards,
Haneef
the problem with TableControlCheckBoxClick
event is that it doesnt get fired if the user checks a checkbox using space bar.
Thanks
>Hi Dinesh,
At runtime, you can set celltype of the child table column using below code:
GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}
Best regards,
Haneef
RA
Rajagopal
Syncfusion Team
July 28, 2007 02:12 AM UTC
Hi Dinesh,
Thanks for your patience.
You could try the code below in the TableControlCurrentCellKeyDown event of the grid, to detect the changes made to the checkbox cells through spacebar.
Let us know if you have any further questions.
Have a nice time.
Regards,
Rajagopal
Thanks for your patience.
You could try the code below in the TableControlCurrentCellKeyDown event of the grid, to detect the changes made to the checkbox cells through spacebar.
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if(e.Inner.KeyCode == Keys.Space && cc.Renderer.StyleInfo.CellType == "CheckBox")
Console.WriteLine("CheckBox state changed");
}
Let us know if you have any further questions.
Have a nice time.
Regards,
Rajagopal
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
DU dinesh upreti
- Jul 25, 2007 04:55 PM UTC
- Jul 28, 2007 02:12 AM UTC