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
4

2 回答 2

5

你需要打电话dataView.syncGridSelection(grid, true)

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

于 2013-03-25T18:27:15.367 回答
3

在挖掘了更多示例之后,我找到了这个示例。

我很快意识到要实现我想要实现的目标,我需要将Slick.Data.DataViewAPi 与以下代码一起使用。

                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);
于 2013-03-20T16:47:22.707 回答