Slickgrid checkbox and filtering problems

帅比萌擦擦* 提交于 2020-01-04 14:30:28

问题


I have a slickGrid which is populated with data, and have a first checkbox column added via:

if (info.includeSelectCheckbox) {
    var checkboxSelector = new Slick.CheckboxSelectColumn({
        cssClass:"slick-cell-checkboxsel"
    });

    info.columns.splice(0, 0, checkboxSelector.getColumnDefinition()); 
}

grid = new Slick.Grid(elem, dataView, info.columns, options);

if (info.includeSelectCheckbox) {
    grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow:false}));
    grid.registerPlugin(checkboxSelector);
    var columnpicker = new Slick.Controls.ColumnPicker(info.columns, grid, options);
}

I also have a filter textbox, which filters the data in the grid by different criteria.

The problem is, when I select the checkbox for some items in the grid and then filter the grid, then selected checkboxes either stay on the old indexes, but matching different records, or are gone from the grid and don't reappear when I the remove filtering.

I'd like to have the checkbox selections independent of the filtering, so whenever I play with the filter the selected items stay selected until I manually uncheck them.

I also tried to add checkboxes via the regular column formatter, but the selection is gone when I start filtering.


回答1:


You need to call dataView.syncGridSelection(grid).

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



来源:https://stackoverflow.com/questions/16357259/slickgrid-checkbox-and-filtering-problems

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!