Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 无法在ext.js中获取itemclick_Extjs - Fatal编程技术网

Extjs 无法在ext.js中获取itemclick

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.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,
    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);})这将更新并获取新值。