大家好。。我有个Tree问题请教一下。不知道 为什么老是报undefined
,那个this.addTreeWin.show() 也是报 this.addTreeWin is undefined,怎么解决呢?
[img]http://dl.iteye.com/upload/attachment/362341/21e5c4d8-5496-3ae9-bd09-25fc65f3e53f.jpg[/img]
代码如下:
MenuTree=Ext.extend(Ext.tree.TreePanel,{
tree_root:null,
tree_menu:null,
addTreeWin:null,
selectNode:null,//当前选择的节点
tabPanel:null,
constructor:function(_tabPanel){
this.tabPanel=_tabPanel;
this.addTreeWin=new addTreeNewWin();
this.addTreeWin.on("addSuccess",function(){
this.tree_root.reload();
this.addTreeWin.hide();
},this);
this.tree_root=new Ext.tree.AsyncTreeNode({
text : '系统配置',
draggable:false,
id:'0'
});
this.tree_menu = new Ext.menu.Menu([
{
text : "添加子树栏目",
iconCls : 'addIcon',// 右键名称前的小图片
handler : function() {
var parentCode = this.selectNode.id;
var parentName = this.selectNode.text;
alert(parentCode+"--"+parentName);
var menuParent = new menu({
parentCode : parentCode,
parentName : parentName
});
this.addTreeWin.show();
}
}, {
text : "刷新树栏目",
iconCls : 'refresh',
handler : function() {
/ ar tree = Ext.getCmp('naviTree');
//tree.root.reload();// 树的重新加载
var tree = Ext.getCmp('naviTree');
tree.root.reload();// 树的重新加载
tree.root.expand(false, false);
}
}]
);
MenuTree.superclass.constructor.call(this,{
id : 'naviTree',
useArrows:true,
animate:true,
autoScroll:true,
containerScroll: true,//是否支持滚动条
deferHeight:true,
split:false,
rootVisible:true,//是否显示根节点
collapseMode:'mini',//在分割线处出现按钮
collapsible: true,
root:this.tree_root,
rootVisible:false,
border:false,
loader:new Ext.tree.TreeLoader({
dataUrl : '../manager/menu!menuAllListInfo.demo'
}),
listeners:{
"contextmenu":{
fn:this.show_menu,
scope:this
}
}
});
this.addEvents("refreshTree");
},
show_menu : function(_node, _e) {
this.selectNode = _node;
//alert(node.parentNode+"----selectNode--"+this.selectNode.id+"-text-"+this.selectNode.text+"-parentNode.id-"+this.selectNode.parentNode.id+"-parentNode.text-"+this.selectNode.parentNode.text);
if (_node.isLeaf())// 子栏目右键工具栏
{
this.tree_menu.showAt(_e.getXY());
} else if (!_node.isLeaf() && _node.parentNode != null)// 树栏目右键工具栏
{
this.tree_menu.showAt(_e.getXY());
} else if (!_node.isLeaf() && _node.parentNode == null)// 树ROOT栏目工具栏
{
this.tree_menu.showAt(_e.getXY());
}
}
});