The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have created master-detail relationship in the grid grouping control to show the child level data below the parent record. I want to get the parent record for the specific child record i have. I tried the record.parentrecord or Record.parent but not able to get the parent record for the child record. Please give me some pointer .
I have tried ParentRecord.GetRelatedRecords(RelationDescriptor) but this is giving me null value.
ADAdministrator Syncfusion Team December 12, 2007 12:46 PM UTC
Given a child record, childRecord, try code like: GridRecord parentRecord = childRecord.ParentChildTable.ParentDisplayElement.GetRecord() as GridRecord;
ADAdministrator Syncfusion Team December 12, 2007 12:59 PM UTC
The above code assumes you have a single GridGroupingControl and are showing the master-details as expandable records in this single grid.
ADAdministrator Syncfusion Team December 12, 2007 01:09 PM UTC
If you are using 2 grids to display the Master-Details, then getting the parent record is straight-forward if the childrecord is being displayed in the child grid. You could just get the CurrentRecord from teh parent grid. Here is code in the child grid's doubleclick event to illustrate this. void parentToChildGrid_TableControlCellDoubleClick(object sender, GridTableControlCellClickEventArgs e) { if (parentTableGrid.Table.CurrentRecord != null) { this.Text = parentTableGrid.Table.CurrentRecord.ToString(); } }
But if you just want to locate the parent record for an abitrary child record whether or not it is being displayed, then I am not sure there is a simple way to do this. One way you could find it is to look through the parentTableGrid.Table.UnsortedRecords collection and just look for the particular field value that would match a parent record to the related childrecord.