我无法在ext.js [4.1..1a GPL]的单元格上触发itemclick事件。我的app.js就像:
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 :(得分: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()
});
}
});