Extjs4 rowEditing 在startEdit 方法上的错误

新学Extjs,做一个表单的CRUD,看到网上有介绍rowEditing插件的就想尝试着用用,但是在startEdit(0,0)这句上会报错,提示Uncaught TypeError: Object 0 has no method 'get' 不知道是什么原因,希望能有人帮忙解释一下。附上grid,store,model,controller的部分代码。

希望大家能不吝赐教。

 

grid:

plugins: [ Ext.create('Ext.grid.plugin.RowEditing', {
    pluginId:'rowEditing',
             saveBtnText: '保存',
             cancelBtnText: "取消",
             clicksToEdit: 1
         }) ],

 

store:

Ext.define("staffManagement.store.staffStore",{
 extend:"Ext.data.Store",
 model:"staffManagement.model.staffModel",
 pageSize:4,
  proxy:{
  type:"ajax",
  waitMsg : '数据加载中...',
  url:"/SSH/js/loadAllStaffAction.action",  
  /*url:"/SSH/js/test.json",*/
  reader:{
   type:"json",
   root:"list",
   totalProperty :'totalCount'  
  },
  writer:{
   type:"json"
  }
  },
 autoLoad:true
});

 

model:

Ext.define("staffManagement.model.staffModel",{
 extend:"Ext.data.Model",
 fields:[
  {name:"userId",type:"int",srotable:true},
  {name:"name",type:"string",srotable:true},
  {name:"userPassword",type:"string",srotable:true},
  {name:"sex",type:"string",srotable:true},
  {name:"birthday",type:"date",srotable:true}
 ]
});

 

controller:

Ext.define("staffManagement.controller.staffController", {
 extend : "Ext.app.Controller",
 init : function() {
  this.getGrid = function(button) {
   return button.ownerCt.ownerCt;
  };
  this.control({
   "staffGrid button[id=add]" : {
    click : function(button) {

     var store = Ext.getStore('staffStore');

     
     var adminObj = Ext.create('staffManagement.model.staffModel',{}); 

   
     store.insert(0,adminObj);
     
     var rowEditing = Ext.getCmp('staffGrid').editingPlugin; 
     
     rowEditing.startEdit(0,0);

  
    }
   },

你应该把下面代码抽出来写
[code="java"]
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
pluginId:'rowEditing',
saveBtnText: '保存',
cancelBtnText: "取消",
clicksToEdit: 1
});
[/code]

然后放到plugins属性中:
[code="java"]
plugins: [rowEditing],
[/code]

把页面的代码都放上来,只有在浏览器中跑了才敢告诉你有没有问题的

ExtJS功能很强大,但是用起来也很麻烦,有时候发生一个错误,怎么也搞不明白,我常用这么一个傻招————推到重来,重新做一遍,一点内容一点内容的增加然后调试。