2012-11-07 219 views
1

我正在使用Extjs 4.1.1。因为我遵循MVC我决定从电网即动“编辑” &“beforeedit”功能(rowEditing插件):要强制编辑和编辑两个工作在控制器?

listeners: {'edit': function(editor, e) { 
    ... 
    },'beforeedit': function(editor, e) { 
    ... 
    }} 

,并把它的内部控制器就像: Ext JS 4 - How to control rowEditor inside controller

我的新代码如下所示这个:

init: function() { 

    this.control({   

     'myGrid': { 
      edit: this.onRowEdit 
     }, 

     'myGrid': { 
      beforeedit: this.onRowBeforeEdit 
     }, 

    }); 

}, 

onRowEdit: function(editor, e) { 
    ... // Fires only when 'beforeedit' not present in this.control 
}, 

onRowBeforeEdit: function(editor, e) { 
    ... // Always fires 
}, 

现在,'beforeedit'开火罚款。我的问题是'编辑'仅在'beforeedit'不存在时触发。任何人有同样的问题?当然,老式的网格监听器似乎对两者都很好。

编辑 我只是认为,如果我定义“beforedit”第一和第二在this.control(“编辑”),该“beforeedit”是不点火的人。

回答

3

把它们放在同一个选择:

init: function() { 

    this.control({   

     'myGrid': { 
      edit: this.onRowEdit, 
      beforeedit: this.onRowBeforeEdit 
     }  
    }); 

} 

它,如果我会做这个同样的问题:

var name = { 
    first: 'John', 
    first: 'Doe' 
}; 
alert(name.first); //will show a messagebox with 'Doe' 
+0

谢谢!现在我也明白为什么它不能按我的方式工作。 – krisk

+0

是的,让我知道它是否有效。 –