I use 5.2 version of Grid. Trying to implement state save and after reload keep apply the saved state.
I checked this topic also but StateProvider.setup('local') is not working. https://bryntum.com/products/grid/examples/state/
My Vue 2 code implementation:
<bryntum-grid
ref="grid"
v-bind="gridConfig"
:data="filteredItems"
class="flex-1"
@cellclick="cellClick"
@selectionchange="selectionChange"
/>
data have variables: gridInstance: null, gridStateId: 'grid.state-id'.
mounted() {
this.gridInstance = this.$refs.grid.instance
if (this.gridInstance) {
const savedState = localStorage.getItem(this.gridStateId)
if (savedState && this.gridInstance) {
const parsedState = JSON.parse(savedState)
this.gridInstance.applyState(parsedState)
}
}
},
methods: {
saveState() {
localStorage.setItem(this.gridStateId, JSON.stringify(this.gridInstance.state))
},
resetState() {
localStorage.removeItem(this.gridStateId)
},
}
I call saveState method on column filtering and I checked the localStorage and the actual state saved there. And tested that state got from localStorage on mounted hook and passed to applyState function correctly. Attached image about localStorage.