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.net/blowsie/LKf6j/
To reproduce the issue take the following steps;
- Select the first item in the grid
- Sort on name
You need to call dataView.syncGridSelection(grid, true)
.
See https://github.com/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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With