2013-03-27 89 views
0

我想創建一個樹面板並在展開節點時向其添加事件,但代碼似乎不適用於我。我已經搜索了幾個小時谷歌,但沒有運氣。任何人都可以看看並告訴我爲什麼?Extjs - 樹面板展開事件

這是我code:提前

Ext.onReady(function() { 
    var store = Ext.create('Ext.data.TreeStore', { 
     root: { 
      expanded: true, 
      children: [{ 
       text: "detention", 
       leaf: true 
      }, { 
       text: "homework", 
       expanded: false, 
       children: [{ 
        text: "book report", 
        leaf: true 
       }, { 
        text: "alegrbra", 
        leaf: true 
       }] 
      }, { 
       text: "buy lottery tickets", 
       leaf: true 
      }] 
     } 
    }); 

    Ext.create('Ext.tree.Panel', { 
     title: 'Simple Tree', 
     width: 200, 
     height: 150, 
     store: store, 
     rootVisible: false, 
     renderTo: Ext.getBody(), 
     listeners: { 
      afteritemexpand: function (node, index, item, eOpts){ 
       alert('HAHA'); 
      } 
     } 
    }); 
}); 

謝謝!

+0

噢沒關係,是我不好,這應該被添加到存儲監聽器,而不是面板 – Bayoneda 2013-03-27 08:26:39

回答