两个slickgrid复选框,用于全选

时间:2015-04-02 13:14:16

标签: javascript jquery checkbox slickgrid

我在光滑网格上有两个复选框列,目前无法使复选框正常工作。如果您检查一侧,另一侧也会被检查,如果您选择所有两侧都检查。有没有办法在slickgrid上重载registerplugin以使两个复选框都单独运行?

我有类似的想法。

switch (new checkboxselected().getcolumn()) {
    case checkboxApprove = grid.registerPlugin(checkboxApprove),
        break
    case checkboxDeny = grid.registerPlugin(checkboxDeny)
}

both columns

Checking on select all selects both columns![][2]

var checkboxApprove = new Slick.CheckboxSelectColumn({
    cssClass: "slick-cell-checkboxsel"
});
columns.push(checkboxApprove.getColumnDefinition());

var checkboxDeny = new Slick.CheckboxSelectColumn({
    cssClass: "slick-cell-checkboxsel"
});
columns.push(checkboxDeny.getColumnDefinition());

$(function () {
    for (var i = 0; i < 10; i++) {
        var d = (data[i] = {});
        d["title"] = "Task " + i;

    }

    grid = new Slick.Grid("#myGrid", data, columns, options);
    grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow: false}));
    grid.registerPlugin(checkboxApprove);
    grid.registerPlugin(checkboxDeny);

    var columnpicker = new Slick.Controls.ColumnPicker(columns, grid, options);

    grid.render();

1 个答案:

答案 0 :(得分:2)

问题是您没有为每列提供唯一的列ID。它们都使用默认ID(_checkbox_selector),因此最终会进行交互。这是一个有根据的猜测,因为我现在无法测试它。

您应该可以通过向传入的选项添加列ID来修复它:

var checkboxDeny = new Slick.CheckboxSelectColumn({
       columnId: "_checkbox_selector_deny"
       cssClass: "slick-cell-checkboxsel"
});