ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Moved column is returned to previous position during filtering after restoring state

Open pu6istiy opened this issue 8 years ago • 3 comments

It's an bug of Save and restore state feature.

You can reproduce that on your tutorial ( http://ui-grid.info/docs/#/tutorial/208_save_state ).

Steps: 0. open http://ui-grid.info/docs/#/tutorial/208_save_state

  1. save state.
  2. move any column.
  3. restore state. (column return to it's saved place)
  4. write something to any column filter. Bug: moved column return to previous position.

pu6istiy avatar May 04 '16 15:05 pu6istiy

Similarly, if you toggle the filter on or off, the columns return to their previous position

ryanburr avatar Jul 18 '16 17:07 ryanburr

Here is a plunker to reproduce the mentioned above. I have narrowed down this problem to the notifyDataChange(uiGridConstants.dataChange.COLUMN) call.

Steps

  1. Click Save
  2. Move columns
  3. Click Restore
  4. Click Notify Data Change

Expected: The columns should stay in the positions they were just ordered Actual: The columns revert to the unsaved state before the restore

http://plnkr.co/edit/ngWqDAjC7w4bnkgloLqV?p=preview

ryanburr avatar Apr 14 '18 15:04 ryanburr

The reply is bit late. But I had similar issue and this is due to the caching of column order. Try the following gridApi.saveState.restore(this.scope, this.scope.tableState); var columnDefsColMov = gridApi.grid.moveColumns.orderCache; columnDefsColMov.length = 0; columnDefsColMov.push.apply(columnDefsColMov, gridApi.grid.columns.slice()); gridApi.core.notifyDataChange(this.uiGridConstants.dataChange.COLUMN);

Harshitha-S-Github avatar Oct 12 '20 00:10 Harshitha-S-Github