5

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;

  1. Select the first item in the grid
  2. Sort on name
Blowsie
  • 40,239
  • 15
  • 88
  • 108

2 Answers2

5

You need to call dataView.syncGridSelection(grid, true).

See https://github.com/mleibman/SlickGrid/wiki/DataView#synchronizing-selection--cell-css-styles

Tin
  • 9,082
  • 2
  • 34
  • 32
3

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);
Blowsie
  • 40,239
  • 15
  • 88
  • 108