extjs ext.tree.panel 添加监听事件

 EXTJS的树,如下方式添加事件,可以响应选择改变、单击,但双击没有响应。而且在选择改变时,同时也会触发单击事件。

问题出在哪里?

var treestore = Ext.create('Ext.data.TreeStore', {
 2     root: {
 3         text:"集团",
 4         id: 'org01',
 5         checked: true,
 6         expanded: true,
 7         children: [
 8             { text: "华南区", id: 'org02', expanded: true},
 9             { text: "华东区", id: 'org03', expanded: true, children: [
10                 { text: "江苏", id: 'org031', leaf: true},
11                 { text: "浙江",  id: 'org032', leaf: true}
12             ] },
13             { text: "华北区",  id: 'org04', expanded: true}
14         ]
15     }
16 });
17 
18 Ext.define('MyApp.Examples.TreeDemo', {
19     extend: 'Ext.panel.Panel',
20 
21     height: 465,
22      653,
23     title: 'My Panel',
24 
25     initComponent: function() {
26         var me = this;
27 
28         Ext.applyIf(me, {
29             items: [
30                 {
31                     xtype: 'treepanel',
32                     height: 430,
33                      200,
34                     autoScroll:true,
35                     animate:true,
36                     id: 'treeOrg',
37              
38                     //默认根目录显示
39                     rootVisible:true,
40                     border:false,
41                     animate:true,
42                     store: treestore,
43                     lines:true,
44                     enableDD:true,
45                     containerScroll:true,                  
46 
47 
48                     listeners: {
49                            
50                             itemdbclick:{                            
51                                 fn: function(view, record, item, index, e,obj){
52                                     alert('dbclick');e.stopEvent;
53                                 },
54                                 scope: this
55                             }
56                             ,
57                              itemclick: {
58                                     fn: function(view, record, item, index, e,obj){
59                                             alert(record.data.id+':'+record.data.text);
60                                             e.stopEvent;
61                                         },
62                                     scope: this
63                             },
64                             checkchange: {
65                                 fn: function(node,checked,obj) {
66                                     alert('checkchange');
67                                     
68                                     
69                                 }
70                             }
71                         }
72 
73                 }
74             ]
75         });
76 
77         me.callParent(arguments);
78     }
79 
80 });

 1

原文地址:https://www.cnblogs.com/baishahe/p/2507341.html