Hello,
I have followed the example of the Hierarchy Grid in the Blazor DataGrid Component. I have not followed the SFDatanager as I use EF
<SfDataManager Url="https://js.syncfusion.com/demos/ejservices/Wcf/Northwind.svc/Orders" CrossDomain="true"></SfDataManager>
The screenshot below shows that child records are displayed but not being filtered to match their respective master ID.
Could you please help?
Hi Sao,
Sorry for the Inconvenience.
We are currently Validating the reported query with high priority at our end, and we will update the further details within two business days. Until then we appreciate your patience.
Regards,
Sarveswaran PK
Hi Sao,
Sorry for the Inconvenience.
We are currently Validating the reported query with high priority at our end, and we will update the further details within two business days. Until then we appreciate your patience.
Regards,
Sarveswaran PK
Hi Sao,
Sorry for the delay and inconvenience caused.
We have analyzed your query and we suggest you to share parent grid records to detail template by context parameter. Because the detail template is a rendered fragment , arguments are passed by context. We have found that you failed to pass the context parameter to the detail Template in your shared sample. This is the reason behind you facing an issue. Kindly refer the attached code snippet and links for your reference.
<DetailTemplate> <h2>Order list of selected emplyee</h2> @{ var employee = (context as EmployeeData); <SfGrid TValue="Order" Query="@GetEmployeesQuery(employee)" AllowSorting=true AllowFiltering="true" AllowPaging="true" AllowGrouping="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update", "ExcelExport", "Search", "Print" })" ContextMenuItems="@(new List<object>() { "AutoFit", "AutoFitAll", "SortAscending", "SortDescending","Copy", "Edit", "Delete", "Save", "Cancel","PdfExport", "ExcelExport", "CsvExport", "FirstPage", "PrevPage","LastPage", "NextPage"})"> . . <GridTemplates> <DetailTemplate Context="CustomerContext"> @{ var orders = (CustomerContext as Order); <SfGrid TValue="CustomerDetails" Query="@GetOrderQuery(orders)"> <SfDataManager Url=https://js.syncfusion.com/demos/ejservices/Wcf/Northwind.svc/Customers CrossDomain="true"></SfDataManager> <GridColumns> <GridColumn Field=@nameof(CustomerDetails.CustomerID) HeaderText="Customer ID" Width="110"></GridColumn> . . </GridColumns> </SfGrid> } </DetailTemplate> </DetailTemplate> } |
Reference: https://blazor.syncfusion.com/demos/datagrid/hierarchy-grid?theme=fluent
https://blazor.syncfusion.com/documentation/datagrid/detail-template#rendering-custom-component
https://blazor.syncfusion.com/documentation/datagrid/templates
Kindly get back to us if you have any further queries.
Regards,
Sarveswaran PK
Dear Sarveswaran,
The main concern is that we don't have the URL mentioned in the SfDataManager for our database.
<SfDataManager Url=https://js.syncfusion.com/demos/ejservices/Wcf/Northwind.svc/Customers CrossDomain="true"></SfDataManager>
We use EF, therefore we ask you whether you have other solutions to address the binding between master and details records in EF by not using the URL mentioned above?
Sao
Hi Sao,
Thanks for contacting Syncfusion support again.
We have analyzed your query and suggest you to refer the attached UG documentation link which is rendered using data source property. Kindly refer the attached link for more information.
Reference: https://blazor.syncfusion.com/documentation/datagrid/detail-template#rendering-custom-component
Please get back to us if you have any further queries.
Regards,
Sarveswaran PK
Dear Sarveswaran,
Thank you very much for your help. I follow the given link. However, error still occur
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Code:
<SfGrid DataSource="@ProductsList" TValue="Product" AllowFiltering="true" AllowPaging="true" AllowSorting=true>
<GridEditSettings Mode="Syncfusion.Blazor.Grids.EditMode.Dialog"></GridEditSettings>
<GridPageSettings PageSize="5"></GridPageSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>
<GridTemplates>
<DetailTemplate>
</DetailTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(Product.ProductCode) HeaderText="Code" TextAlign="TextAlign.Center" Width="20"> </GridColumn>
<GridColumn Field=@nameof(Product.Description) HeaderText="Description/ឈ្មោះផលិតផល" Width="60"></GridColumn>
<GridColumn Field=@nameof(Product.Strength) Width="20"></GridColumn>
<GridColumn Field=@nameof(Product.IssueUnit) Width="20"></GridColumn>
<GridColumn Field=@nameof(Product.Category) Width="20"></GridColumn>
<GridColumn Field=@nameof(Product.DiscontinueDate) HeaderText="Disc. Date" Width="20"></GridColumn>
<GridColumn Field=@nameof(Product.ForReport) DisplayAsCheckBox=true Width="20"></GridColumn>
</GridColumns>
</SfGrid>
@code {
private SfGrid<vStockStatusAllLevel>? GLDefaultGrid;
private SfGrid<Product>? ProductGrid;
public IEnumerable<Product>? ProductsList { get; set; }
public IEnumerable<vStockStatusAllLevel>? ListStockStatusAll { get; set; }
protected override void OnInitialized()
{
ProductsList = DBServices.GetAllProduct();
ListStockStatusAll = DBServices.GetAllStockStatusAllLevel();
}
}
Best regards
Sao
Hi Sao,
Thanks for contacting Syncfusion support again.
We have analyzed your query and would like to inform you that we bind parent grid TValue to the context value. But from your shared code snippet product is bind in parent grid and typecast vStockStatusAllLevel in the context. This is the reason for an issue you are facing. Kindly refer the attached link for your reference.
Reference: https://blazor.syncfusion.com/documentation/datagrid/detail-template#rendering-custom-component
Kindly get back to us if you have any further queries.
Regards,
Sarveswaran PK