我有一个网格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();
}
}
我遇到了同样的问题,发现这是可行的,但有点麻烦。
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();
}
}