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

How to know the Parent Row of the GridGroupingControl

I'm using GridGroupingControl.I have two tables t1 and t2 which are related through the column "Description" .t1 is parent of t2.When I click on any DataGrid cell of child table, how can i know to which parent row it is related to?. The rows of parent table may contain the same child rows as other child row.

Thanks & Regards,
Ramana.

1 Reply

RC Rajadurai C Syncfusion Team October 15, 2009 12:31 PM UTC

Hi Ramana,

Thanks for your interest in Syncfusion Products.

You can get the parent row details to which a particular child record belongs by accessing the DisplayElement. Please refer to the following code handled in TableControlCellClick event.

GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (style.TableCellIdentity.Table.TableDescriptor.Name == "ChildTable")
{
Element ele = style.TableCellIdentity.DisplayElement;
Element el = ele.ParentTable.RelationParentTable.CurrentElement;
Record r1 = el.GetRecord();
if(r1 != null)
MessageBox.Show(r1.Info);
}
}

This code triggers the message box with parent record details when a child record is clicked.

Sample:
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F90630.zip

Regards,
Rajadurai

Loader.
Live Chat Icon For mobile
Up arrow icon