0

我有一个定义如下的网格 js。我已经选择了我想要选择/取消选择所有行的所有复选框。我能够执行全选,但取消全选不起作用。任何人都可以请帮忙。谢谢。

const grid = new gridjs.Grid({
        columns: [
            {
                id: "selectId", name: "Select",
                plugin: {
                    component: gridjs.plugins.selection.RowSelection,
                    props: {id: (row) => row.cell(1).data}
                }
            },
            { id: "columnName", name: "Column Name" },
            { id: "dataType", name: "Data Type"}
        ],
        data: [],
    });

function init(){
    grid.render("#data-grid);
}

function loadGrid(){
    $.get("/someURL",function(response) {
        if(response.success){
            fileSchemaGrid.updateConfig({
                data: response.data
            }).forceRender();
        }
    });
}

function toggle(){
    if($("#checkbox-select-all-rows").is(":checked")){
        //This block works
        fileSchemaGrid.config.columns[0].data = true;
        fileSchemaGrid.forceRender();
    }else{
        //*** This block does not work***
        fileSchemaGrid.config.columns[0].data = false
        fileSchemaGrid.forceRender();
    }
}
4

1 回答 1

0

我有同样的问题,发现这行得通 - 但它有点 hacky。

function toggle(){
if($("#checkbox-select-all-rows").is(":checked")){
    //This block works
    fileSchemaGrid.config.columns[0].data = true;
    fileSchemaGrid.forceRender();
}else{
    //*** This block should now work***
    fileSchemaGrid.config.columns[0].data = null;
    fileSchemaGrid.config.plugin.get('selectId').props.store.state.rowIds = [];
    fileSchemaGrid.forceRender();
}

}

于 2022-02-16T22:19:10.573 回答