let grid: Grid = new Grid({
dataSource: employeeData,
allowSorting: true,
enablePersistence: true,
columns: [
{
field: "EmployeeID",
headerText: "Employee ID",
textAlign: "Right",
width: 125
},
{ field: "FirstName", headerText: "Name", width: 125 },
{ field: "Title", headerText: "Title", width: 180 },
{ field: "City", headerText: "City", width: 110 },
{ field: "Country", headerText: "Country", width: 110 }
],
childGrid: {
dataSource: orderDatas,
queryString: "EmployeeID",
enablePersistence: true,
allowSorting: true,
load: load,
created: created,
allowPaging: true,
columns: [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
width: 120
},
{ field: "ShipCity", headerText: "Ship City", width: 120 },
{ field: "Freight", headerText: "Freight", width: 120 },
{ field: "ShipName", headerText: "Ship Name", width: 150 }
]
}
});
grid.appendTo("#Grid");
function load() { //load event of child grid,
this.element.id = "child_" + this.parentDetails.parentKeyFieldValue;
}
function created() {
var persistData = JSON.parse(localStorage.getItem("grid" + this.element.id));
if (persistData) {
this.setProperties(persistData);
}
} |
var grid = new ej.grids.Grid({ dataSource: window.employeeData,
allowSorting: true,
enablePersistence: true,
columns: [
{
field: "EmployeeID",
headerText: "Employee ID",
textAlign: "Right",
width: 125
},
{ field: "FirstName", headerText: "Name", width: 125 },
{ field: "Title", headerText: "Title", width: 180 },
{ field: "City", headerText: "City", width: 110 },
{ field: "Country", headerText: "Country", width: 110 }
],
childGrid: {
dataSource: window.hierarchyOrderdata,
queryString: "EmployeeID",
enablePersistence: true,
allowSorting: true,
load: load,
created: created,
columns: [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
width: 120
},
{ field: "ShipCity", headerText: "Ship City", width: 120 },
{ field: "Freight", headerText: "Freight", width: 120 },
{ field: "ShipName", headerText: "Ship Name", width: 150 }
]
}
});
grid.appendTo("#Grid");
|
Index.js
ej.base.enableRipple(true);
var grid = new ej.grids.Grid({
dataSource: window.employeeData,
allowSorting: true,
enablePersistence: true,
columns: [
{
field: "EmployeeID",
headerText: "Employee ID",
textAlign: "Right",
width: 125
},
{ field: "FirstName", headerText: "Name", width: 125 },
{ field: "Title", headerText: "Title", width: 180 },
{ field: "City", headerText: "City", width: 110 },
{ field: "Country", headerText: "Country", width: 110 }
],
childGrid: {
dataSource: window.hierarchyOrderdata,
queryString: "EmployeeID",
enablePersistence: true,
allowSorting: true,
load: load,
created: created,
columns: [
{
field: "OrderID",
headerText: "Orderds",
textAlign: "Right",
width: 120
},
{ field: "ShipCity", headerText: "City", width: 120 },
{ field: "Freight", headerText: "Freight", width: 120 },
{ field: "ShipName", headerText: "Ship Name", width: 150 }
]
}
});
grid.appendTo("#Grid");
function load() {
this.element.id = "child_" + this.parentDetails.parentKeyFieldValue;
var persistData = JSON.parse(localStorage.getItem("grid" + this.element.id));
if (persistData) {
this.pageSettings = persistData.pageSettings;
this.sortSettings = persistData.sortSettings;
this.filterSettings = persistData.filterSettings;
this.groupSettings = persistData.groupSettings;
this.selectedRowIndex = persistData.selectedRowIndex;
this.searchSettings = persistData.searchSettings;
}
}
|