在构建treeGrid的时候,只要在后台传的参数中,有‘id’属性,就会默认保存为tree的node的值,当你点击的时候(动态加载),则会默认将此id值传往后台。
MenuTree = Ext.extend(Ext.tree.Panel,{ _appCode : 'SYS', constructor : function(_config) { if (_config == null) { _config = {}; } Ext.apply(this,_config); MenuTree.superclass.constructor.call(this,{ autoScroll : true, border : false, rootVisible : true, height : this._height, columnWidth : .2, store : new Ext.data.TreeStore( { proxy : { type : 'ajax', url : 'sys/menu-info-manage!tree.action', reader : 'json' }, autoLoad : true, root : { text : '所有菜单', id : '0', expanded : true }, listeners : { 'beforeload' : { fn : function(_store,_op,_e){ _op.params.appCode = this._appCode }, scope : this } } }), listeners : { 'itemclick' : { fn : this.onTreeNodeClick, scope : this } } }); }, /** * 树的节点单击事件 * * @param {} * _node 节点 * @param {} * _e */ onTreeNodeClick : function(_tree,_record,_node,_index,_e) { if(_record.get('id')==0) this._panel.setBtStatus('root'); else{ this._panel.setBtStatus('node'); this._panel._form.loadDataHandler(_record.get('id')); } }, onUpdateData : function(_selNode,_data){ if(_data.id!=_selNode.get('id')) _selNode.set('id',_data.id); else if(_data.text!=_selNode.get('text')) _selNode.set('text',_data.text); else if(_data.leaf!=_selNode.get('leaf')) _selNode.set('leaf',_data.leaf); } });
后台传往前台的 map对象,
@Override public Map<String,Object> attributes() { Map<String,Object> attrs = new HashMap<String,Object>(); attrs.put("id",guId); attrs.put("text",menuName); attrs.put("linkUrl",linkUrl); attrs.put("leaf",new Boolean(leaf)); //attrs.put("icon",icon); attrs.put("menuType",menuType); attrs.put("appCode",appCode); attrs.put("orders",orders); attrs.put("menuCode",menuCode); return attrs; } (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|