2012-11-14 5 views
2

플러그인을 사용하여 격자에 RowEditing 유효성 검사를 취소하면 'validateedit'에 사용자 정의 오류 메시지를 표시하는 방법은 무엇입니까?Extjs 4 rowediting 사용자 정의 유효성 검사

validateedit : function(editor, e) { 

    if (condition) { 
    e.cancel = true; 
    // how to add an error message to a field 
    } 
} 

답변

1

그냥 당신이 내장 된 모델 유효성 검사를 사용하고 form.markInvalid()으로 전체 Errors 컬렉션을 보낼 수 있습니다 선택기 및 방법 양식과 연관이 필드를

editor.editor.getForm().findField('fieldName').markInvalid('Message here');

8

를 사용합니다. 이렇게하면 각 필드를 개별적으로 처리 할 필요가 없습니다.

validateedit: function(editor, e, eOpts){ 
    var newModel = e.record.copy(); //copy the old model 
    newModel.set(e.newValues); //set the values from the editing plugin form 

    var errors = newModel.validate(); //validate the new data 
    if(!errors.isValid()){ 
     editor.editor.form.markInvalid(errors); //the double "editor" is correct 
     return false; //prevent the editing plugin from closing 
    } 
} 

Reference

은 당신이 return false 대신 e.cancel = true 사용해야합니다. e.cancel = true 여전히 열려있는 행 편집기에서 후속 편집 작업도 실패합니다. 그런 다음 취소 버튼을 클릭하고 편집을 다시 시작하려면 행을 다시 편집해야합니다.

관련 문제