2017-08-03 72 views
0

我是一個新的ext.js,我想弄明白爲什麼我從http://docs.sencha.com/extjs/6.5.1/guides/quick_start/handling_events.html 教程中借用的這個例子對我不起作用。在ext.js網格中的項目監聽器不工作

我添加了兩個聽衆代碼: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' 
}] 
}); 
+3

您使用的是現代或古典的工具? –

+0

我使用經典之作。 – Chapka

回答

0

經典的事件是itemclick。你正在看的樣品是現代的。

0

正如我在煎茶小提琴已經檢查itemtap工作正常,現代但對於經典你有用戶itemlick。我使用的同一代碼在我的小提琴,你可以檢查以下鏈接給出: -

EXTJS GRID ITEM 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() 
    } 
});