Slickgrid checkbox and filtering problems

2019-07-20 17:07发布

问题:

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.



标签: slickgrid