How to load details using SfDataGrid_DetailsViewExpanding

I was trying to load details to a master records on demand, but unfortunately the record is not reflecting in the sfDataGrid, Is there anything I'm missing


My event is as follows:

private async void SfDataGrid_DetailsViewExpanding(object sender, DetailsViewExpandingEventArgs e)

        {

            BusyIndicator buysIndicator = new BusyIndicator();

            buysIndicator.Show(sfDataGridPurchaseList.TableControl);

            PurchaseOrderItem orderInfo = e.Record as PurchaseOrderItem;

            var purchaseOrderDetails = await purchaseLogic.GetPurchaseOrderItemDetailsByOrderId(orderInfo.OrderId);

            e.DetailsViewDataSource.Add("OrderItemDetails", purchaseOrderDetails);

            buysIndicator.Hide();

        }

____________________________________


this.sfDataGridPurchaseList.DetailsViewExpanding += SfDataGrid_DetailsViewExpanding;

                // GridViewDefinition for DataGrid

                sfDataGridPurchaseList.AutoGenerateRelations = false;


                GridViewDefinition firstLevelGridViewDefinition = new GridViewDefinition

                {

                    RelationalColumn = "OrderItemDetails",


                };

                SfDataGrid firstLevelNestedGrid = new SfDataGrid();

                firstLevelNestedGrid.AutoGenerateColumns = false;

                firstLevelNestedGrid.DataSource = firstLevelGridViewDefinition;



                //// Disabling AutoGenerateColumns and manually defining columns for first level DataGrid.

                firstLevelNestedGrid.AutoGenerateColumns = false;

                firstLevelNestedGrid.Columns.Add(new GridTextColumn() { MappingName = "ProductName", HeaderText = "Product", AllowEditing = false });

                firstLevelGridViewDefinition.DataGrid = firstLevelNestedGrid;


                sfDataGridPurchaseList.DetailsViewDefinitions.Add(firstLevelGridViewDefinition);


can someone help me to find what I'm doing wrong in this?



3 Replies 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team June 30, 2023 02:04 PM UTC

Hi Jayakrishnan R,

Please find the response for the reported queries below,

Query

Response


private async void SfDataGrid_DetailsViewExpanding(object sender, DetailsViewExpandingEventArgs e)

        {

            BusyIndicator buysIndicator = new BusyIndicator();

            buysIndicator.Show(sfDataGridPurchaseList.TableControl);

            PurchaseOrderItem orderInfo = e.Record as PurchaseOrderItem;

            var purchaseOrderDetails = await purchaseLogic.GetPurchaseOrderItemDetailsByOrderId(orderInfo.OrderId);

            e.DetailsViewDataSource.Add("OrderItemDetails", purchaseOrderDetails);

            buysIndicator.Hide();

        }

 


We have checked the reported issue with the provided details. Unfortunately, the reported problem does not reproduce on our end. The added DetailsViewDataGrid populated properly as expected. Here, we have attached the tested sample for your reference. Please have a look at this. Could you please confirm if we missed anything? If you are still facing the reported issue, modify the attached sample and share the video illustration of the reported issue. It will be helpful for us to check on it and provide you with a solution at the earliest.


this.sfDataGridPurchaseList.DetailsViewExpanding += SfDataGrid_DetailsViewExpanding;

                // GridViewDefinition for DataGrid

                sfDataGridPurchaseList.AutoGenerateRelations = false;

 

                GridViewDefinition firstLevelGridViewDefinition = new GridViewDefinition

                {

                    RelationalColumn = "OrderItemDetails",

 

                };

                SfDataGrid firstLevelNestedGrid = new SfDataGrid();

                firstLevelNestedGrid.AutoGenerateColumns = false;

                firstLevelNestedGrid.DataSource = firstLevelGridViewDefinition;

 

 

                //// Disabling AutoGenerateColumns and manually defining columns for first level DataGrid.

                firstLevelNestedGrid.AutoGenerateColumns = false;

                firstLevelNestedGrid.Columns.Add(new GridTextColumn() { MappingName = "ProductName", HeaderText = "Product", AllowEditing = false });

                firstLevelGridViewDefinition.DataGrid = firstLevelNestedGrid;

 

                sfDataGridPurchaseList.DetailsViewDefinitions.Add(firstLevelGridViewDefinition);

 


We are a little unclear about this scenario, in the provided code snippet you are trying to add the relation through the DetailsViewExpanding event. How did you make the DataGrid has DetailsView before defining the Relation? If we have misunderstood your requirement, we kindly request you provide more information about your specific scenario.

 


Regards,
Dhanasekar M.

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


Attachment: SfDataGridDemo_5a15180a.zip

Marked as answer

JR Jayakrishnan R June 30, 2023 04:18 PM UTC

Thank you, I have fixed the issue. The mistake I do is, I tried to load the data async. When I change that, then it is working as expected



DM Dhanasekar Mohanraj Syncfusion Team July 3, 2023 01:32 PM UTC

Jayakrishnan R,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.


Loader.
Up arrow icon