View Full Version : saving state for grids with no "id" on columns

21 May 2014, 1:55 AM
I've finally tracked down an issue on grids where I want to save the state (column sizes etc)

It seems unless you use "id" for the columns - each time the grid loads - the headers have a potentially different dynamically generated id - and so the columns dont match - and the width settings are not used..

I've gotten around it using something like :

beforestaterestore: function (grid, state, eOpts)
var a;
if (state && state.columns && state.columns.length && grid && grid.columns && grid.columns.length) {
for (a = 0; a < state.columns.length; a++) {
state.columns[a].id = grid.columns[a].headerId;

Because - I don't want to have to use "id" - as the grid could be displayed more than once..
(Obviously - it would be fine if it used itemId..)

Is this the best approach ?
Any other ideas ?

21 May 2014, 2:01 AM
What if you set stateId on columns?

21 May 2014, 2:15 AM
Excellent :)

I thought I'd already tried that - but that seems to do the job nicely !