v7.3.0
SupportExamplesFree Trial

GridState
Mixin

Mixin for Grid that handles state. It serializes the following grid properties:

  • rowHeight
  • selectedCell
  • selectedRecords
  • columns (order, widths, visibility)
  • store (sorters, groupers, filters)
  • scroll position
  • collapsed group records
  • tree group levels

See State for more information on state.

targetElement.innerHTML = '<p>Click the first button to store grids state, rearrange the grid, then click the second one to restore</p>'; // button to store state const storeButton = new Button({ appendTo : targetElement, text : 'Store', onClick : () => { // grid.state fetches the grids current state localStorage.setItem('docs-grid-state', JSON.stringify(grid.state)); Toast.show('State stored'); } }); // button to restore state const restoreButton = new Button({ appendTo : targetElement, text : 'Restore', onClick : () => { const state = JSON.parse(localStorage.getItem('docs-grid-state')); // assigning to grid.state applies a state to the grid if (state) grid.state = state; Toast.show('State restored'); } }); // grid with cell editing const grid = new Grid({ appendTo : targetElement, // makes grid as high as it needs to be to fit rows autoHeight : true, data : DataGenerator.generateData(5), columns : [ // We strongly recommend using id on columns when storing Grid state, to be // certain that the state is applied to the correct column { field : 'name', id : 'name', text : 'Name', flex : 1 }, { field : 'city', id : 'city', text : 'City', width : 150 }, { field : 'color', id : 'color', text : 'Color', width : 150 } ] });

See also

  • State - Base state mixin
  • Grid - The Grid widget
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isGridState : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of GridState class, or subclass thereof.
  • Gets or sets grid's state. Check out GridState mixin for details.

Functions

Functions are methods available for calling on the class

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class

    Type definitions

    Source path

    Grid/view/mixin/GridState.js

    Demo

    examples/state

    Contents