Extjs 无法在ext.js中获取itemclick
我无法在ext.js[4.1..1a GPL]中的cellclick上触发itemclick事件。我的app.js如下所示:Extjs 无法在ext.js中获取itemclick,extjs,Extjs,我无法在ext.js[4.1..1a GPL]中的cellclick上触发itemclick事件。我的app.js如下所示: Ext.application({ name: 'HelloExt', launch: function() { var k = Ext.create('Ext.panel.Panel', { title: 'Tic Tac Toe', width: 300, height: 300, layou
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);
}
}
});
}
});
任何人都请帮忙
谢谢此侦听器不存在于面板中。您至少需要一个视图。下面的示例捕获每个“字段”的单击事件
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()
});
}
});
然而,SRA这里剩下的是如何获取放置在每个面板中的文本,例如,如何获取html中的值:'@Satya html是一种静态属性,在呈现组件后被删除。因此,您必须处理dom才能接收值,但可以使用update设置新值。只需将事件回调主体更改为
p.body.on('click',function(){p.update('B');alert(p.getTargetEl().dom.innerHTML);})代码>这将更新并获取新值。