ExtJS4 treepanel 主要添加viewConfig重的代码:
xtype:‘treepanel‘, store: menuStore, id:‘menuTreePanel‘, viewConfig : { //checkbox联动 onCheckboxChange : function(e, t) { var item = e.getTarget(this.getItemSelector(), this.getTargetEl()), record; if (item){ record = this.getRecord(item); var check = !record.get(‘checked‘); record.set(‘checked‘, check); if (check) { record.bubble(function(parentNode) { parentNode.set(‘checked‘, true); parentNode.expand(false, true); }); record.cascadeBy(function(node) { node.set(‘checked‘, true); node.expand(false, true); }); } else { record.cascadeBy(function(node) { node.set(‘checked‘, false); }); } } } }, /* selModel: { selType: ‘checkboxmodel‘ },*/ columns: [ { xtype:‘treecolumn‘,text: ‘菜单名称‘,width:450, dataIndex: ‘text‘,sortable:false}, { text: ‘菜单ID‘,hidden:true,hideable:false, dataIndex: ‘id‘,align:‘center‘,sortable:false} ]
效果图:
效果图
时间: 2024-10-06 07:01:09