npm.io
0.4.0 • Published 2 years ago

proton-state

Licence
MIT
Version
0.4.0
Deps
6
Size
60 kB
Vulns
0
Weekly
0

proton-state

examples

https://codesandbox.io/s/github/ptrushin/proton-state-examples

Try to play:

  • Add filter Category - Address bar and Grid changed
  • Add filter Product, it depends on Category
  • Change filter on column OrderDate in Gird - Address bar and Grid changed
  • Click with alt key on cell in column Quantity - all filtered by its value - Address bar and Grid changed
  • Now you can copy address from address bar and open it in other tab - all filters applied
  • Change column order and reload page, now aggird state store in localstorage and you can copy/paste state

install

npm install proton-state

add to AgGrid

in component ctor

this.protonState = new ProtonState(
{
    history: props.history,
    onChange: this.onStateChange
});

in componentDidMount and componentDidUpdate

this.protonState.updateState();

in onGridReady AgGrid event

onGridReady = params => {
    this.protonState.addStateProvider(new AgGridStateProvider({api: params.api}))
    ...