2016-09-21 10 views
2

編集アクションボタンでjQgridのインライン編集を使用していますが、aftersavefuncが機能しません。それを行う正しい方法は何ですか?アクションを使用したjqgridのインライン編集

私は、行を復元したいと私は、サーバーから受信したときにエラーメッセージが表示さ:

{「成功」:偽、「ID」:ヌル、「メッセージを」「あなたが行うことができません」}次は私のコードです:

angular.element(document).ready(function() { 

    $("#jqGrid").jqGrid({ 
     datatype: "local", 
     data: $scope.listResellerUser, 
     mtype: "POST", 
     colModel: [ 
      { label:'Full Name', name: 'fullname' }, 
      { label: 'User Name', name: 'username' }, 
      { label: 'User Id', name: 'userId', hidden: true, key:true }, 
      { label: 'Email', name: 'email' }, 
      { label: 'User Level', name:'roleId', index:'roleId', edittype:'select', editable:true, align:'center', formatter:'select', 
       editoptions:{value:setRoleDropdown() 
      }}, 
      {name:'Actions',index:'Actions',width:55,align:'center',sortable:false,search: false,formatter:'actions', 
       formatoptions:{ 
        keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing. 
        delbutton:false, 
       }} 

     ], 
     editurl: "/myreseller/changeuserrole", 
     styleUI : 'Bootstrap', 
     page: 1, 
     autowidth: true, 
     height: 250, 
     rowNum: 20, 
     scrollPopUp:true, 
     scrollLeftOffset: "83%", 
     viewrecords: true, 
     scroll: 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records 
     emptyrecords: 'Scroll to bottom to retrieve new page', // the message will be displayed at the bottom 
     pager: "#jqGridPager", 
     editParams: { 
      "aftersavefunc": function (rowid, response, options) { 
       alert("row with rowid=" + rowid + " is successfuly modified."); 
      } 
     } 
    }); 

答えて

0

まず第一に、それはあなたが使用(または使用可能)jqGridのバージョンに関する情報、およびjqGridのフォーク(free jqGridGuriddo jqGrid JS商用または古いものを含めることが重要ですjqGridバージョン< = 4.7)を質問のテキストに入力してください。

無料のjqGridフォークを開発しました。これはブートストラップもサポートしています(here参照)。したがって、私はGuriddo jqGrid JSの特定の問題でお手伝いできません。それは私のようですが、存在しないオプションeditParamsを使用しています。無料のjqGridでは、inlineEditingオプション(the wiki article参照)を介して一般的なインライン編集オプションを指定することができます。商用のGuriddo jqGrid JSをご利用の場合は、のコールバック関数をformatoptionsと指定する必要があります(the documentationonSuccessonErrorafterSaveおよびその他のコールバックを参照)。

また、コールバックaftersavefuncはあなたのケースでは間違った選択であるようです。のサーバレスポンス処理後にと呼ばれます。成功したHTTPステータスコードを持つediturlのすべての応答は成功と解釈され、変更が間違って変更されてグリッドに保存されます。問題を解決するには、errorfuncコールバックといくつかのエラーHTTPステータスコード(> = 400)を返すか、またはsuccessfuncコールバックを使用してサーバレスポンスのコンテンツを処理し、サーバの内容に応じて[false, "error text"]またはを返すことができます応答。それはあなたに必要なものだと私には思われます。

関連する問題