最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SlickGrid selection issues on sort - Stack Overflow

programmeradmin4浏览0评论

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;

  1. Select the first item in the grid
  2. 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/

To reproduce the issue take the following steps;

  1. Select the first item in the grid
  2. Sort on name
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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

You 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);
发布评论

评论列表(0)

  1. 暂无评论