简体   繁体   English

ext.js中网格中的Itemtap侦听器不起作用

[英]Itemtap listener in grid in ext.js not work

I'm a new in ext.js and I'm trying to figure why this example I borrowed from tutorial on http://docs.sencha.com/extjs/6.5.1/guides/quick_start/handling_events.html doesn't work for me. 我是ext.js ,我想弄清楚为什么我从http://docs.sencha.com/extjs/6.5.1/guides/quick_start/handling_events.html上的教程中借来的示例为我工作。

I added two listeners to code: itemmouseenter - it's work correctly, and itemtap - it's not working. 我在代码中添加了两个侦听器: itemmouseenter正常工作,而itemtap不工作。

Ext.create('Ext.tab.Panel', {
    renderTo: Ext.getBody(),
    xtype: 'tabpanel',
    items: [{
  title: 'Employee Directory',
  xtype: 'grid',
  iconCls: 'x-fa fa-users',
  listeners: {
    itemmouseenter: function() {
      console.log( 'Mouse Enter');
    },
    itemtap: function(view, index, item, e) {
        console.log("item tap")
    }
  },
  store: {
      data: [{
          "firstName": "Jean",
          "lastName": "Grey",
          "officeLocation": "Lawrence, KS",
          "phoneNumber": "(372) 792-6728"
      }, {
          "firstName": "Phillip",
          "lastName": "Fry",
          "officeLocation": "Lawrence, KS",
          "phoneNumber": "(318) 224-8644"
      }, {
          "firstName": "Peter",
          "lastName": "Quill",
          "officeLocation": "Redwood City, CA",
          "phoneNumber": "(718) 480-8560"
      }]
  },
  columns: [{
      text: 'First Name',
      dataIndex: 'firstName',
      flex: 1
  }, {
      text: 'Last Name',
      dataIndex: 'lastName',
      flex: 1
  }, {
      text: 'Phone Number',
      dataIndex: 'phoneNumber',
      flex: 1
  }]
  }, {
     title: 'About Sencha',
     iconCls: 'x-fa fa-info-circle'
 }]
});

In classic the event is itemclick . 传统上,事件是itemclick The sample you're looking at is for modern. 您正在查看的样本是现代的。

As I have checked in sencha fiddle itemtap is working fine for modern but for Classic you have to user itemlick . 正如我已经检查过的sencha fiddle一样, itemtap对于Modern来说工作正常,但对于Classic,您必须使用itemlick I am using your same code in my fiddle you can check by given below link:- 我在提琴中使用了相同的代码,您可以通过以下链接进行检查:-

EXTJS GRID ITEM TAP EXTJS网格项目TAP

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var panel = Ext.create('Ext.window.Window', {
            width:'100%',
            height:'100%',
            layout:'fit',
            items:[{
                xtype: 'tabpanel',
                items: [{
                    title: 'Employee Directory',
                    xtype: 'grid',
                    layout:'fit',
                    iconCls: 'x-fa fa-users',
                    listeners: {
                        itemmouseenter: function() {
                            console.log('Mouse Enter');
                        },
                        itemclick: function(grid, record, item, index, e, eOpts) {
                            Ext.Msg.alert('Info',`You have tapped on ${index+1} item`);
                        }
                    },
                    store: {
                        data: [{
                            "firstName": "Jean",
                            "lastName": "Grey",
                            "officeLocation": "Lawrence, KS",
                            "phoneNumber": "(372) 792-6728"
                        }, {
                            "firstName": "Phillip",
                            "lastName": "Fry",
                            "officeLocation": "Lawrence, KS",
                            "phoneNumber": "(318) 224-8644"
                        }, {
                            "firstName": "Peter",
                            "lastName": "Quill",
                            "officeLocation": "Redwood City, CA",
                            "phoneNumber": "(718) 480-8560"
                        }]
                    },
                    columns: [{
                        text: 'First Name',
                        dataIndex: 'firstName',
                        flex: 1
                    }, {
                        text: 'Last Name',
                        dataIndex: 'lastName',
                        flex: 1
                    }, {
                        text: 'Phone Number',
                        dataIndex: 'phoneNumber',
                        flex: 1
                    }]
                }, {
                    title: 'About Sencha',
                    iconCls: 'x-fa fa-info-circle'
                }]
            }]
        });
        panel.show()
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM