Index.cshtml
<div class="container">
<ejs-grid id="Grid" allowPaging="true" dataSource="ViewBag.DataSource" detailDataBound="detailDataBound" detailTemplate="#detailtemplate1">
<e-grid-pagesettings pageSize="7"> </e-grid-pagesettings> <e-grid-columns> ... </ejs-grid> </div> <script type="text/x-template" id="detailtemplate1"> <div class="detailgridone"></div>
<div class="detailgrid2"></div>
</script>
<script> function detailDataBound(e) {
var firstdetailgrid = new ej.grids.Grid({
dataSource: [],
height: 300,
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
firstdetailgrid.appendTo(e.detailElement.querySelector('.detailgridone'));
var secGrid = new ej.grids.Grid({ dataSource: [],
height: 300,
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 110 },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
secGrid.appendTo(e.detailElement.querySelector('.detailgrid2')); |
index.cshtml
<script type="text/x-template" id="detailtemplate1">
<div class="detailgridone"></div>
<div class="detailgrid2"></div>
</script>
function detailDataBound(e) {
let data = [{
OrderID: 10248, CustomerID: 'VINET', EmployeeID: 5, OrderDate: new Date(8364186e5),
ShipName: 'Vins et alcools Chevalier', ShipCity: 'Reims', ShipAddress: '59 rue de l Abbaye',
...
]{
let firstgrid = new ej.grids.Grid({
dataSource: [],
columns: [
{ field: 'EmployeeID', headerText: 'Employee ID', width: 110 }
]
});
firstgrid.appendTo(e.detailElement.querySelector('.detailgridone'));
let queryString = 'EmployeeID'; // queryString used
let query = new ej.data.Query().where(queryString, 'equal', e.data.EmployeeID); // parentKeyFieldValue used
new ej.data.DataManager({ json: data }).executeQuery(query).then((e) => {
firstgrid.dataSource = e.result;
})
let secondgrid = new ej.grids.Grid({
dataSource: [],
columns: [
{ field: 'EmployeeID', headerText: 'EmployeeID', width: 110 }
]
});
secondgrid.appendTo(e.detailElement.querySelector('.detailgrid2'));
queryString = 'EmployeeID'; // queryString used
query = new ej.data.Query().where(queryString, 'equal', e.data.EmployeeID); // parentKeyFieldValue used
new ej.data.DataManager({ json: data }).executeQuery(query).then((e) => {
secondgrid.dataSource = e.result;
}) |