Javascript Dojo Dgrid:选中“取消选择标题”复选框
我正在使用Dojo“dgrid/OnDemandGrid”。因为我正在为每一行使用其内置的复选框功能 问题是,每当我逐个选择所有复选框时,其标题复选框(即“全选”复选框)未被选中,与每当我逐个取消选择所有复选框时相同,则“全选”复选框未被取消选中仍处于混合状态。有三种状态是正确的、错误的和混合的 当我搜索解决方案时,我发现这是DojodGrid本身的一个bug。 这是您可以检查的URLJavascript Dojo Dgrid:选中“取消选择标题”复选框,javascript,html,dojo,dgrid,Javascript,Html,Dojo,Dgrid,我正在使用Dojo“dgrid/OnDemandGrid”。因为我正在为每一行使用其内置的复选框功能 问题是,每当我逐个选择所有复选框时,其标题复选框(即“全选”复选框)未被选中,与每当我逐个取消选择所有复选框时相同,则“全选”复选框未被取消选中仍处于混合状态。有三种状态是正确的、错误的和混合的 当我搜索解决方案时,我发现这是DojodGrid本身的一个bug。 这是您可以检查的URL 请帮助我解决此问题,谢谢。当您单独选择行时,用于更新标题复选框(allSelected)的属性不会更新。你可能
请帮助我解决此问题,谢谢。当您单独选择行时,用于更新标题复选框(allSelected)的属性不会更新。你可能是对的,可能是个bug。你报告了吗 我能想到的解决方案是自己更新标题复选框的状态。下面是执行相同操作的代码
grid.on('dgrid-select', function () {
var selectedRows = [];
for (var e in grid.selection) {
grid.selection[e] && selectedRows.push(e)
}
//get the selector column and checkbox from that column
var column = grid.columns["select"];
var headerCheckbox = column._selectorHeaderCheckbox;
if (selectedRows.length === grid.get('total')) {
//update the checkbox when the selection count equal to total count.
headerCheckbox.indeterminate = false;
headerCheckbox.checked = true;
headerCheckbox.setAttribute('aria-checked', 'true');
grid.allSelected = true;
}
});
grid.on('dgrid-deselect', function () {
var selectedRows = [];
for (var e in grid.selection) {
grid.selection[e] && selectedRows.push(e)
}
//get the selector column and checkbox from that column
var column = grid.columns["select"];
var headerCheckbox = column._selectorHeaderCheckbox;
if (selectedRows.length === 0) {
headerCheckbox.indeterminate = false;
headerCheckbox.checked = false;
headerCheckbox.setAttribute('aria-checked', 'false');
grid.allSelected = false;
}
});
希望这有帮助。当您单独选择行时,用于更新标题复选框(allSelected)的属性不会更新。你可能是对的,可能是个bug。你报告了吗 我能想到的解决方案是自己更新标题复选框的状态。下面是执行相同操作的代码
grid.on('dgrid-select', function () {
var selectedRows = [];
for (var e in grid.selection) {
grid.selection[e] && selectedRows.push(e)
}
//get the selector column and checkbox from that column
var column = grid.columns["select"];
var headerCheckbox = column._selectorHeaderCheckbox;
if (selectedRows.length === grid.get('total')) {
//update the checkbox when the selection count equal to total count.
headerCheckbox.indeterminate = false;
headerCheckbox.checked = true;
headerCheckbox.setAttribute('aria-checked', 'true');
grid.allSelected = true;
}
});
grid.on('dgrid-deselect', function () {
var selectedRows = [];
for (var e in grid.selection) {
grid.selection[e] && selectedRows.push(e)
}
//get the selector column and checkbox from that column
var column = grid.columns["select"];
var headerCheckbox = column._selectorHeaderCheckbox;
if (selectedRows.length === 0) {
headerCheckbox.indeterminate = false;
headerCheckbox.checked = false;
headerCheckbox.setAttribute('aria-checked', 'false');
grid.allSelected = false;
}
});
希望这是有帮助的