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

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致