ui-grid
ui-grid copied to clipboard
Moved column is returned to previous position during filtering after restoring state
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
- save state.
- move any column.
- restore state. (column return to it's saved place)
- write something to any column filter. Bug: moved column return to previous position.
Similarly, if you toggle the filter on or off, the columns return to their previous position
Here is a plunker to reproduce the mentioned above. I have narrowed down this problem to the notifyDataChange(uiGridConstants.dataChange.COLUMN)
call.
Steps
- Click Save
- Move columns
- Click Restore
- 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
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);