zw19900913 2013-04-23 12:35
浏览 377
已采纳

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);

  
    }
   },

  • 写回答

3条回答 默认 最新

  • Dead_Knight 2013-04-23 13:25
    关注

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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?