When using SlickGrids selection
and sorting
together I found that the selection is storing the index of the selected rows rather than storing the selection for the data you selected.
How can I fix this so that the selected data is remembered instead of just an index?
A demo of the issue can be found here: /
To reproduce the issue take the following steps;
- Select the first item in the grid
- Sort on name
When using SlickGrids selection
and sorting
together I found that the selection is storing the index of the selected rows rather than storing the selection for the data you selected.
How can I fix this so that the selected data is remembered instead of just an index?
A demo of the issue can be found here: http://jsfiddle/blowsie/LKf6j/
Share Improve this question edited Mar 20, 2013 at 13:42 Blowsie asked Mar 20, 2013 at 10:32 BlowsieBlowsie 40.6k15 gold badges91 silver badges110 bronze badgesTo reproduce the issue take the following steps;
- Select the first item in the grid
- Sort on name
2 Answers
Reset to default 5You need to call dataView.syncGridSelection(grid, true)
.
See https://github./mleibman/SlickGrid/wiki/DataView#synchronizing-selection--cell-css-styles
After digging through a few more of the examples I found this example.
I soon realised to do what I want to achieve I needed to use the Slick.Data.DataView
APi with the following code.
dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});
// initialize the model after all the events have been hooked up
dataView.beginUpdate();
dataView.setItems(files);
dataView.endUpdate();
dataView.syncGridSelection(grid, true);