index.cshtml
@Html.EJS().Grid("FlatGrid").Load("load").Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width("150").Add();
...
<script>
var List = [{ OrderID: 12345, CustomerID: "VINET", Country: "Italy", State: "france" },
{ OrderID: 12345, CustomerID: "SUPRD", Country: "Italy", State: "france" },
{ OrderID: 12345, CustomerID: "HANAR", Country: "Italy", State: "france" },
{ OrderID: 12345, CustomerID: "TOMSP", Country: "Italy", State: "france" }
]
function load(args) {
this.dataSource = List;
}
</script> |
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;
}) |