|
ej.base.enableRipple(true);
var savedProperties;
var grid = new ej.grids.Grid({
dataSource: window.employeeData,
allowSorting: true,
enablePersistence: true,
allowFiltering: 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 },
],
});
grid.appendTo('#Grid');
document.getElementById('btnsave').addEventListener('click', onSave);
document.getElementById('btnrestore').addEventListener('click', onRestore);
function onSave() {
localStorage.setItem("myitem",grid.getPersistData()); // get the current grid state here.
console.log(savedProperties);
}
function onRestore() {
var loadpersistData = JSON.parse(localStorage.getItem("myitem"));
grid.setProperties(loadpersistData); // set the properties to restore the state.
console.log(loadpersistData);
}
|