var treeStore = Ext.create('Ext.data.TreeStore', { root : { expanded : true, children : [{ text : "detention", leaf : true }, { text : "homework", expanded : true, checked : false, children : [{ text : "book report", checked : false, expanded : true, children : [{ text : "buy lottery tickets", checked : false, expanded : true, leaf : true }, { text : "buy lottery tickets3", checked : false, expanded : true, leaf : true }] }, { text : "alegrbra", checked : false, expanded : true, leaf : false, children : [{ text : "buy lottery tickets2", checked : false, leaf : true }, { text : "buy lottery tickets3", checked : false, expanded : true, leaf : true }] }] }, { text : "buy lottery tickets", leaf : true }] } }); var treePanel = Ext.create('Ext.tree.Panel', { width : 200, height : 250, store : treeStore, rootVisible : false, checked : true, defaults : { checked : false } }); treePanel.on('checkchange', function(record, checked) { if (checked) { record.bubble(function(parentNode) { parentNode.set('checked', true); }); record.cascadeBy(function(node) { node.set('checked', true); }); } else { record.cascadeBy(function(node) { node.set('checked', false); }); record.bubble(function(parentNode) { if ('Root' != parentNode.get('text')) { var flag = true; for (var i = 0; i < parentNode.childNodes.length; i++) { var child = parentNode.childNodes[i]; if (child.get('checked')) { flag = false; continue; } } if (flag) { parentNode.set('checked', false); } } }); } }, treePanel); var win = Ext.widget('window', { title : '修改客服权限', closeAction : 'hide', width : 400, height : 300, layout : 'fit', resizable : true, modal : true, buttonAlign : 'center', items : treePanel, listeners : { 'beforehide' : function() { fromForm.getForm().reset(); } }, buttons : [{ text : '修改', id : 'update_btn', handler : function() { addOrUpdateAction('update'); } }, { text : '关闭', handler : function() { win.hide(); } }] });