Maximize productivity with
30% off* for a limited time
using BOOSTDEV30.
Includes 3- and 5-packs.
*Some exclusions may apply.New Product LaunchBoldDesk: Help desk ticketing software starts at $10 for 3 agents.
Try it for free.
export class FilterComponent implements OnInit {
...
@ViewChild('grid')
public grid: GridComponent;
...
public onChange(e: ChangeEventArgs): void {
let data: string = this.grid.getPersistData(); //get persist data
}
}
|
export class FilterComponent implements OnInit {
...
@ViewChild('grid')
public grid: GridComponent;
...
public setState(): void {
let persistedData: Object; //Grid state saved in server.
.....
this.grid.setProperties(persistedData); //get persist data
this.grid.refresh();
}
}
|
[app.component.ts]
storeFn(args) {
var persistData = this.gridObj.getPersistData();
var data = JSON.stringify(persistData);
window.localStorage.setItem("gridPersistData", data);
this.columns = Object.assign([], this.gridObj.columns);
var colValues = [];
// header text property of the columns are stored separately in window local storage
this.columns.forEach(col => colValues.push({ headerText: col.headerText }));
window.localStorage.setItem("gridCol", JSON.stringify(colValues));
}
resetFn(args) {
var getPersistedData = JSON.parse(
window.localStorage.getItem("gridPersistData")
);
var persistData = JSON.parse(getPersistedData);
var colsData = JSON.parse(window.localStorage.getItem("gridCol"));
if (persistData) {
var i = 0;
// Header text properties of the stored data is restored to the persisted column object
while (i < persistData.columns.length) {
persistData.columns[i].headerText = colsData[i].headerText;
i++;
}
console.log("setting grid: ", persistData, this.columns);
this.gridObj.setProperties(persistData);
}
} |