2012-11-07 2 views
1

Extjs 4.1.1을 사용하고 있습니다. 내가 MVC를 따라 때문에 내가 그리드 예에서 '편집'& 'beforeedit'기능 (rowEditing 플러그인)를 이동하기로 결정사전 편집 및 강제 편집 모두 Controller에서 작동합니까?

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

예, 작동하는지 알려주세요. –