2013-02-20 75 views
1

我有一个treepanel,里面有treepanel的节点。要识别展开或折叠我使用下面的代码的节点是否TreePanel中,而不是:extjs treepanel展开崩溃事件

Ext.getCmp(“通用”)倒塌

返回值是true或false。在treepanel展开或折叠时,是否可以捕获树中的事件?我指的是treepanel,而不是面板中的节点。

您的帮助表示感谢。

谢谢。

回答

2

你一定错在这里做一些事情,下面的代码工作,看到这个JSFiddle

Ext.create('Ext.tree.Panel', { 
    collapsible: true, 
    title: 'Simple Tree', 
    width: 200, 
    height: 150, 
    store: store, 
    rootVisible: false, 
    renderTo: Ext.getBody(), 
    listeners: { 
     collapse: function() { 
      alert('collapsed'); 
     }, 
     expand: function() { 
      alert('expand') 
     } 
    } 
}); 
+0

我尝试添加的崩溃和我的听众展开事件,它仍然无法正常工作。 – 2013-02-20 07:15:20

+0

然后你需要分享更多的代码,因为这对我很有用,应该为你工作。你在哪里以及如何宣布听众? – 2013-02-20 07:37:30

+0

ID: 'accountTreePnl', 名称: 'accountTreePnl', 高度:250, 的xtype: “TreePanel中”, rootVisible的:假的, 边界:假的, 动画:假的, 自动滚屏:真实, containerScroll:真, 根:新Ext.tree.AsyncTreeNode({ 文本: '帐户(S)' }), 装载机:新Ext.tree.TreeLoader({ dataUrl: '' }), dropConfig:{ appendOnly:true }, 听众:{ collapse:函数(){ }, expand:function(){ } } – 2013-02-20 07:57:49

1

“扩大”和“崩溃”不,我没有工作。相反,'itemcollapse','itemexpand','itemmove'和他们的同事确实为我工作。我与Ext-JS 4.2.1。

+0

您使用了错误的事件。你需要使用afteritemexpand事件。 afteritemexpand:function(node,index,item,eOpts)alert('Dharmesh'); } 这是小提琴: http://jsfiddle.net/johanhaest/RDC9W/1/ – 2016-05-25 11:37:55

0

您使用了错误的事件。你需要使用afteritemexpand事件。

afteritemexpand: function (node, index, item, eOpts){ 
    alert('HAHA'); 
} 

这里有一个小提琴:

http://jsfiddle.net/johanhaest/RDC9W/1/