2012-11-20 20 views
1

我無法觸發ext.js [4.1..1a GPL]中cellclick上的itemclick事件。我的app.js是這樣的:無法在ext.js中觸發itemclick

Ext.application({ 
    name: 'HelloExt', 
    launch: function() { 
var k = Ext.create('Ext.panel.Panel', { 
     title: 'Tic Tac Toe', 
     width: 300, 
     height: 300, 
    layout: { 
      type: 'table', 
      // The total column count must be specified here 
      columns: 3 
     }, 
     defaults: { 
      // applied to each contained panel 
      bodyStyle:'padding:20px' 
     } 
    , 
     items: [{ 
      html: '', 
     },{ 
      html: '', 
     },{ 
      html: '' 
     },{ 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
     ], 
     renderTo: Ext.getBody(), 
    listeners : 
    { 
     itemclick: function(dv, record, item, index, e) { 
      alert(record); 
     } 
    } 
    }); 
} 
}); 

任何人都請幫忙。

謝謝

回答

0

這個監聽器對於面板不存在。您至少需要一個視圖。以下示例捕獲每個「字段」的點擊事件。

Ext.application({ 
    name: 'HelloExt', 
    launch: function() { 
var k = Ext.create('Ext.panel.Panel', { 
     title: 'Tic Tac Toe', 
     width: 300, 
     height: 300, 
    layout: { 
      type: 'table', 
      // The total column count must be specified here 
      columns: 3 
     }, 
     defaults: { 
      // applied to each contained panel 
      bodyStyle:'padding:20px', 
      listeners: { 
       afterRender: function(p) { 
        p.body.on('click', function() { alert(p.id) }); 
       } 
      } 
     } 
    , 
     items: [{ 
      html: '' 
     },{ 
      html: '', 
     },{ 
      html: '' 
     },{ 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
    { 
      html: '' 
     }, 
     ], 
     renderTo: Ext.getBody() 
    }); 
} 
}); 
+0

你搖滾的人:) – Satya

+0

@Satya不客氣;)但是 – sra

+0

SRA剩下在這裏是如何得到它放置在每個小組內的文本,例如我如何獲得HTML內的值:'' – Satya