Extjs treeGrid的node的值

前端之家收集整理的这篇文章主要介绍了Extjs treeGrid的node的值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在构建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; }

原文链接:https://www.f2er.com/ajax/165881.html

猜你在找的Ajax相关文章