這裏你去! Working fiddle
=>您添加的偵聽器checkchange,檢查它是否具有的childNodes如果是這樣設置的的childNodes
值
注:檢查數據有checked: false
參數啓用的複選框。 (如果不通過後端發送您可以將它添加到你的模型並將其設置爲默認強制)
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true, checked: false },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true, checked: false },
{ text: "algebra", leaf: true, checked: false}
], checked: false },
{ text: "buy lottery tickets", leaf: true, checked: false }
]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
listeners: {
checkchange: function(node, checked, eOpts){
if(node.hasChildNodes()){
node.eachChild(function(childNode){
childNode.set('checked', checked);
});
}
}
}
});
來源
2014-01-24 12:08:36
VDP
你給一個extjs 1.0例子的參考是否你使用Ext4.2就像標籤一樣? – VDP
是的,我使用ExtJs4.2.I提供了鏈接供參考。 – Dev