Index.cshtml
<div class="container">
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowFiltering="true" detailDataBound="detailDataBound" detailTemplate="#detailtemplate1">
<e-data-manager url="/Home/UrlDatasource" adaptor="UrlAdaptor" crossdomain="true"></e-data-manager>
. . .
</ejs-grid>
</div>
<script type="text/x-template" id="detailtemplate1">
<div class="detailgridone"></div>
<div class="detailgridtwo"></div>
<div class="detailgridthree"></div>
</script>
<script>
function detailDataBound(e) {
var data = new ej.data.DataManager({
url: "/Home/childUrlDataSource",
adaptor: new ej.data.UrlAdaptor,
crossDomain: true
});
var firstdetailgrid = new ej.grids.Grid({
dataSource: data,
load: function (args) {
this.query = new ej.data.Query().addParams("EmployeeID", e.data.EmployeeID) // Pass the parent grid row data to server end
},
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
firstdetailgrid.appendTo(e.detailElement.querySelector('.detailgridone'));
var seconddetailGrid = new ej.grids.Grid({
dataSource: data,
load: function (args) {
this.query = new ej.data.Query().addParams("EmployeeID", e.data.EmployeeID)
},
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
seconddetailGrid.appendTo(e.detailElement.querySelector('.detailgridtwo'));
var thirdgrid = new ej.grids.Grid({
dataSource: data,
load: function (args) {
this.query = new ej.data.Query().addParams("EmployeeID", e.data.EmployeeID)
},
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
thirdgrid.appendTo(e.detailElement.querySelector('.detailgridthree'));
}
</script>
[HomeController.cs]
public IActionResult childUrlDataSource([FromBody]extendDM dm) {
List<OrdersDetails> DataDetails = new List<OrdersDetails>();
var ord = dm.@params["EmployeeID"]; //get the parent grid data in server side while pass this data through addParams
OrdersDetails val = OrdersDetails.GetAllRecords().Where(or => or.EmployeeID == ord).FirstOrDefault();
DataDetails.Add(val);
return dm.RequiresCounts ? Json(new { result = DataDetails, count = DataDetails.Count }) : Json(DataDetails);
} |