2012-12-14 27 views
0

我可以訪問控制器中的列表(作爲項目的容器),但我不知道如何訪問列表項屬性。列表組件:如何檢測哪個項目被選中?

如何創建正確的ComponentQuery規則?我嘗試了'list> item',但它不起作用。

每個項目都有它的標題,但在selectSection中我得到'undefined'作爲輸出。

Ext.define('UGP.controller.BeginList', 
      {    
       extend: 'Ext.app.Controller', 
       config: 
       { 
        views: [ 'BeginList' ], 
        control: 
        { 
         'list': 
         { 
          select: 'selectSection' 
         } 
        } 
       }, 

       selectSection: function() 
       { 
        Ext.Msg.alert('title=' + this.title); 
       } 
      } 
); 

與List組件中BeginList.js:

Ext.define('UGP.view.BeginList', 
      { 
       extend: 'Ext.List', 

       config: 
       { 
        fullscreen: true, 
        itemTpl: '{title}', 
        data: 
        [ 
         { title: 'Chapter 1', id: 0, action: "selectSection" }, 
         { title: 'Chapter 2', id: 1, action: "selectSection" }, 
         { title: 'Chapter 3', id: 2, action: "selectSection" }, 
         { title: 'Chapter 4', id: 3, action: "selectSection" } 
        ] 
       } 
      } 
); 

回答

1

你可以它傳遞參數的select事件文檔中看到。所以,你可以你的selectSection功能的簽名改成這樣:

selectSection: function (list, record) { 
    Ext.Msg.alert('title=' + record.get('title')); 
} 

您也可以看看這通常是一個用於檢測一個列表項自來水事件itemTap事件。

希望這會有所幫助

相關問題