我使用增强的网格增强了网格,其中一个列已下拉。 要求是在点击复选框后我想要禁用行以及选择框。 但问题是在窗口或列调整大小时启用选择框。 这是代码。
<html>
<div id="gridDiv"></div>
</html>
<script>
dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojox.grid.enhanced.plugins.IndirectSelection");
dojo.ready(function () {
var data = {
identifier: 'id',
items: []
};
var data_list = [{
col2: false,
col3: 'But are not followed by two hexadecimal'
}, {
col2: false,
col3: 'Because a % sign always indicates'
}, {
col2: false,
col3: 'Signs can be selectively'
}];
var rows = 4;
for (var i = 0, l = data_list.length; i < rows; i++) {
data.items.push(dojo.mixin({
id: i + 1
}, data_list[i % l]));
}
var store = new dojo.data.ItemFileWriteStore({
data: data
});
/*set up layout*/
var layout = [{
cells: [{
'name': 'Column 1',
'field': 'id',
'width': '100px'
}, {
'name': 'Column 2',
'field': 'col2',
'width': '100px'
}, {
'name': 'Column 3',
'field': 'col3',
'width': '200px'
}, {
'name': 'Column 4',
'field': 'col4',
'width': '150px',
alwaysEditing: true,
editable: true,
type: 'dojox.grid.cells.Select',
options: ['new', 'read', 'replied']
}]
}];
/*create a new grid:*/
var grid = new dojox.grid.EnhancedGrid({
id: 'grid',
store: store,
structure: layout,
plugins: {
indirectSelection: {
headerSelector: false,
width: "10px",
styles: "text-align: center;"
}
}
},
document.createElement('div'));
/*append the new grid to the div*/
dojo.byId("gridDiv").appendChild(grid.domNode);
/*Call startup() to render the grid*/
grid.startup();
dojo.connect(dijit.byId('grid'), 'onSelected',
function (rowIndex) {
dijit.byId('grid').rowSelectCell.setDisabled(rowIndex, true);
dijit.byId('grid').getCell(4).getEditNode(rowIndex).setAttribute('disabled', true);
});
});
</script>
以下是jsfiddle链接:http://jsfiddle.net/ZgH8z/1/
请注意我不应该禁用列大小调整,因为列可以根据需要增加。