网格双击,RowEditing抛出:Uncaught TypeError:无法读取未定义的属性'apply'

时间:2014-08-20 09:46:21

标签: model-view-controller grid extjs4

我明白了 未捕获的TypeError:无法读取未定义的属性“apply” 当我双击网格行时。我不确定为什么会这样。

我已阅读此内容[How to access plugin in ExtJs MVC 和[Uncaught TypeError: Cannot read property 'apply' of undefined with Sencha

这是代码。

Ext.define('App.view.admin.PersonsGrid' ,{
extend:'Ext.grid.Panel',
requires: ['Ext.grid.plugin.RowEditing', 'Ext.toolbar.Paging'],
alias:'widget.admin-personsgrid',
title:'People',
itemId:'personGrid',
autoScroll:true,
selType: 'rowmodel',
plugins: [
          {
              ptype: 'rowediting',
              //clicksToEdit: 1,
              clicksToMoveEditor: 2,
              autoCancel: false,
              pluginId: 'rowediting'
          }
      ],
   ],
tbar:[
      {text:'Add Person', itemId:'add'},
      {text:'Edit Person', itemId:'edit'},
      {text:'Remove Person', itemId:'remove'},
      '->',
      'Search:',
      {
        xtype:'textfield',
        name:'searchValueField',
        width:200,
     },
     {
         text:'Submit',
         itemId: 'submit',

     }
  ],
  initComponent: function() {
    this.store = Ext.create('Ext.data.Store',{
        model:'App.model.Person',
        remoteFilter:true,
        remoteSort:true,
        pageSize:100
    });
     this.columns = [
                    {
                       text:'Last Name', dataIndex:'lastName',
                       editor: {xtype: 'textfield', allowBlank: false}
                    },
                    {
                        text:'First Name', dataIndex:'firstName',
                        editor: {xtype: 'textfield', allowBlank: false}
                    },
                    {
                       text:'Email', dataIndex:'email',
                       editor: {vtype: 'email', allowBlank: false}
                    },
                    {
                        text:'Org Unit', dataIndex:'orgUnitName',
                        editor: {xtype: 'textfield', allowBlank: false},
                    },
                    {
                        text:'Location', dataIndex:'name', editor: {
                        xtype: 'textfield', allowBlank: false}
                     },
                     {
                          text:'Office Phone', dataIndex:'officePhone',editor: {
                          xtype: 'textfield', allowBlank: false},
                     },
                     {
                          text:'Mobile Phone', dataIndex:'mobilePhone',editor: {
                          xtype: 'textfield', allowBlank: false}
                     },
                     {
                          text:'Home Phone', dataIndex:'homePhone',editor: {
                          xtype: 'textfield', allowBlank: false}
                     }

     ];
          this.dockedItems = [
                  {
                    xtype: 'pagingtoolbar',
                    ui: 'footer',
                    defaultButtonUI: 'default',
                    dock: 'bottom',
                    displayInfo: true,
                    store: this.store
                  }
            ];    
        this.callParent( arguments );
    } 

});

1 个答案:

答案 0 :(得分:2)

好, 我收到了这个奇怪的消息,因为在控制器中我正在捕获事件 itemdblclick

'grid[xtype=admin-personsgrid] ' : {
      edit: this.savePerson,
      cancelEdit: this.cancelPersonEdit,
      beforerende: this.loadPersonRecords,
     **itemdblclick: this.personDoubleClicked,**
     itemcontextmenu: this.showpersonContextMenu
},

对于itemdblclick:this.personDoubleClicked,
我没有写任何函数来处理双击。 因此错误突然出现。 我禁用了双击,因为我现在不需要它。 为extjs学到的经验。如果不需要,请不要添加监听器。