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     width: 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                     width: 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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM