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?
Hi Jayakrishnan R,
Please find the response for the reported queries below,
|
Query |
Response |
|
{ 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(); }
|
|
|
// 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);
|
|
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
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
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.
- 3 Replies
- 2 Participants
- Marked answer
-
JR Jayakrishnan R
- Jun 30, 2023 04:29 AM UTC
- Jul 3, 2023 01:32 PM UTC