I have a class data source that loads the data in the parent grid correctly. I am programming Razor page using c# and ASP.NET
The class looks like below
Header Class:
Detail Class:
Can you please advise and guide me in the right direction to have the details grid work correctly. Right now, the details are not loading.
Thank you
|
<div>
@{
var ChildGrid = new Syncfusion.EJ2.Grids.Grid() {
QueryString = "EmployeeID",
Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
----
}
};
}
<ejs-grid id="Grid1" dataSource=Model.Datasource2 childGrid="ChildGrid" detailDataBound="detailDataBound" allowPaging="true">
-----
</ejs-grid>
</div>
<script>
function detailDataBound(args){
// bind the nested data from the parent grid datasource directly to the childGrid
args.childGrid.dataSource = args.data.FamilyMembers;
}
</script>
|
|
<div>
@{
var ChildGrid2 = new Syncfusion.EJ2.Grids.Grid() {
DataSource = Model.ChildDataSource,
QueryString = "EmployeeID",
Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
---
}
};
}
<ejs-grid id="Grid2" dataSource=Model.Datasource2 childGrid="ChildGrid2" allowPaging="true">
----
</ejs-grid>
</div>
|
Thank you for the example. That helped a lot.
One last question - Is there a way to set it up so that the child grid will open expanded?
Thank you
|
[index.cshtml]
<ejs-grid id="Grid" dataSource=Model.Datasource childGrid="ChildGrid" dataBound="dataBound" allowPaging="true">
---
</ejs-grid>
</div>
<script>
function dataBound(args) {
var gridIns = document.getElementById("Grid").ej2_instances[0]; // get the Grid instances
gridIns.detailRowModule.expandAll(); // expand all the child-Grids
}
</script>
|