2012-11-07 207 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

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