Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141106 | Nov 23,2018 05:03 PM UTC | Feb 26,2021 07:35 AM UTC | Angular - EJ 2 | 7 |
![]() |
Tags: Grid |
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);
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.