答案 0 :(得分:0)
向包含复选框的列添加侦听器:
columns: [
{
xtype: 'checkcolumn',
listeners: {
checkchange: 'onCheckcolumnCheckChange'
}
},
// ....
]
然后使用此函数检查/取消选中检查事件
上的父节点onCheckcolumnCheckChange: function(checkcolumn, rowIndex, checked, eOpts) {
var view = this.getView();
var item = this.getStore().data.items[rowIndex];
var columnName = checkcolumn.dataIndex;
// User unchecked a row: refresh the view
if(!checked){
view.refresh();
return;
}
// User checked a row: unselect all parents
var parentNode = item.parentNode;
while(typeof parentNode != 'undefined' && parentNode !== null && !parentNode.data.root){
parentNode.set(columnName, false);
parentNode = parentNode.parentNode;
}
// Then uncheck all childs (recusif)
(function doChild(children){
if(typeof children == 'undefined' || children === null || children.length <= 0)
return;
for(var i=0; i<children.length; i++){
children[i].set(columnName, false);
doChild(children[i].childNodes); // <= recursivity
}
})(item.childNodes);
view.refresh();
}