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;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章