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

How to get the correct parent row when there are multiple sub grids expanded?

When you expand multiple rows of a master detail grid the property CurrentItem always returns the value of the last parent row clicked. I have attached a demo project demonstrating this. 

In the picture below I am hovering over the PersonId column field. In the tooltip you can clearly see that the currentitem is reporting to me "dbo.Company". That is because  "dbo.Company" was the last parent row I clicked open.

I need a way to get the parent row of the current details grid, regardless of what the current index or item is.


Attachment: SfDataGridDemo_ff5840ef.zip

3 Replies

VS Vijayarasan Sivanandham Syncfusion Team October 31, 2022 02:14 PM

Your requirement to get the main grid data in ToolTipOpening event can be achieved by getting the RowIndex of ChildDataGrid using GetDetailsViewDataGridRowIndex helper method. Refer to the below code snippet,

if (e.Record != null)


    //Here get the child DataGrid

    var detailsViewDataGrid = e.OriginalSender as DetailsViewDataGrid;


    if (detailsViewDataGrid != null)


        //Here get the parentDataGrid

        var parentDataGrid = detailsViewDataGrid.GetTopLevelParentDataGrid();


        if (parentDataGrid != null)


            //Here get the RowIndex of ChildDataGrid  

            var childRowIndex = parentDataGrid.GetDetailsViewDataGridRowIndex(detailsViewDataGrid);


            if (childRowIndex > -1)


                //Here get the parent rowIndex by subtract 1 value from childRowIndex

                var parentRowIndex = childRowIndex - 1;


                if (parentRowIndex > -1)


                    //Here get the parent record index

                    var parentRecordIndex = parentDataGrid.TableControl.ResolveToRecordIndex(parentRowIndex);


                    if (parentRecordIndex > -1)


                        //here get the parent record           

                        var record = parentDataGrid.View?.Records[parentRecordIndex];


                        if (record != null)


                            //Here know the properties of the primary item to which the secondary grid belongs.

                            //Here you can access that main datagrid data

                            var datatable = record.Data as DatabaseTable;

                            var col = e.Record as DatabaseTableColumn;

                            //Here you can assign the secondary grid the order id as maingrid order id        

                            tt = $"{datatable.Name} {col.Name} {col.DataType}";








Find the modified sample in the attachment.

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.

Attachment: SfDataGridDemo_a832e087.zip

TI Tim November 2, 2022 12:19 PM

TY Vijay, that worked perfectly

VS Vijayarasan Sivanandham Syncfusion Team November 3, 2022 09:47 AM

If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you😊.

Live Chat Icon For mobile
Up arrow icon