2014-11-07 4 views
0

안녕하세요. 형식 작업을 통해 jqgrid 편집 기능을 사용하고 있습니다. 그것은 가능한 방법입니다 beforeSubmit 및 perfrom 유효성 검사 메서드를 사용할 수 있습니다.제출 기능이 jqgrid에서 실행되지 않습니다.

formatoptions: { 
         keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing. 
         onEdit: function (rowid) { 
          //alert("in onEdit: rowid=" + rowid + "\nWe don't need return anything"); 
         }, 
         onSuccess: function (jqXHR) { 
          $('input[id*="gs_"]').val(""); 
          $grid.setGridParam({ search: false, postData: { "filters": ""} ,datatype: 'json'}).trigger("reloadGrid"); 
          // the function will be used as "succesfunc" parameter of editRow function 
          // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow) 
          /*alert("in onSuccess used only for remote editing:" + 
           "\nresponseText=" + jqXHR.responseText + 
           "\n\nWe can verify the server response and return false in case of" + 
           " error response. return true confirm that the response is successful"); 
          // we can verify the server response and interpret it do as an error 
          // in the case we should return false. In the case onError will be called 
          return true;*/ 
         }, 
         onError: function (rowid, jqXHR, textStatus) { 
          // the function will be used as "errorfunc" parameter of editRow function 
          // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow) 
          // and saveRow function 
          // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow) 
          /*alert("in onError used only for remote editing:" + 
           "\nresponseText=" + jqXHR.responseText + 
           "\nstatus=" + jqXHR.status + 
           "\nstatusText" + jqXHR.statusText + 
           "\n\nWe don't need return anything");*/ 
         }, 
         afterSave: function (rowid) { 
          //alert("in afterSave (Submit): rowid=" + rowid + "\nWe don't need return anything"); 
         }, 
         afterRestore: function (rowid) { 
          //alert("in afterRestore (Cancel): rowid=" + rowid + "\nWe don't need return anything"); 
         }, 
         delOptions: myDelOptions 
        } 
    }  ], 

기능이 절대로 실행되지 않습니다. 나는

Kidnly 도움 감사를 제공, 검증 목적으로 아약스 요청을 perfrom 할

답변

2

인라인 편집에 beforeSaveRow있다 (당신이있는 jqGrid의 일부 이전 버전을 사용하지 않는 경우). 콜백은 formatter: "actions"formatoptions의 내부에 설정 될 수는 없지만, 대신 $.jgrid.inlineEdit를 사용할 수 있습니다

$.extend(true, $.jgrid.inlineEdit, { 
    beforeSaveRow: function (options, rowid) { 
     ... 
     return true; // return false break submiting 
    } 
}); 
+0

감사 선생님, 나는 시도하고 당신을 업데이트합니다 :) – user2375298

+0

안녕 올렉, 나는에 나의 행 데이터를 전송해야한다면 서버, 유효성을 검사하기 위해 서버에 보낼 수 있도록 데이터를 serialize하는 방법 – user2375298

+1

@ user2375298 : 미안하지만 원하는 것을 완전히 이해하지 못합니다. 나는 네 질문을 이해했다 : 왜'beforeSubmit'이 해고되지 않는 걸까요? 내 대답은 인라인 편집에 사용할 수있는'beforeSaveRow' 대신'beforeSubmit' 양식 편집 콜백을 사용하려고했습니다. 검증을위한 가장 좋은 방법은 * 다른 질문입니다. 나는 당신의 전체 시나리오를 모른다. 서버 측 유효성 검사를위한 추가 단계가 필요 없다고 생각합니다. 서버가 잘못된 입력 데이터를 발견하면 해당 오류 메시지와 일부 오류 HTTP 코드 만 리턴해야합니다. – Oleg

관련 문제