2016-05-27 22 views
0

jqgridは、行が選択されたときに別のビュー(MVC4)に行のデータを送信します。しかし、行の情報を編集すると(私はインライン編集を使用しています)、このビューは変更されません。インライン編集後に起こっているイベントを見つけることができません。これはjsです。行の編集後にビューを変更するにはどうすればよいですか。インライン編集後に発生するイベント

$(function() { 
$("#GridTable").jqGrid({ 
    url: "/Goods/GoodsList", 
    editurl: "/Goods/Edit", 
    datatype: 'json', 
    mtype: 'Get', 
    colNames: ['GoodId', 'Имя', 'Цена'], 
    colModel: [ 
     { key: true, hidden: true, name: 'GoodId', index: 'GoodId', editable: true }, 
     { 
      key: false, name: 'GoodName', index: 'GoodName', editable: true, sortable: true, 
      editrules: { 
       required: true, custom: true, custom_func: notATag 
      } 
     }, 
     { 
      key: false, name: 'Price', index: 'Price', editable: true, sortable: true, formatter: numFormat, 
      unformat: numUnformat, 
      //sorttype: 'float', 
      editrules: { required: true, custom: true, custom_func: figureValid} 
     }, ], 
    pager: jQuery('#pager'), 
    rowNum: 10, 
    rowList: [10, 25, 50, 100], 
    height: '100%', 
    viewrecords: true, 
    caption: 'Список товаров', 
    sortable: true, 
    emptyrecords: 'No records to display', 
    cellsubmit : 'remote', 
    jsonReader: { 
     root: "rows", 
     page: "page", 
     total: "total", 
     records: "records", 
     repeatitems: false, 
     Id: "0" 
    }, 
    //to get good's full view when row is selected 
    onSelectRow: 

     function() { 
      var myGrid = $('#GridTable'), 
      selRowId = myGrid.jqGrid('getGridParam', 'selrow'), 
      celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId'); 
      $.ajax({ 
       url: "/Goods/DetailInfo", 
       type: "GET", 
       data: { id: celValue } 
      }) 
      .done(function (partialViewResult) { 
       $("#goodDetInfo").html(partialViewResult); 
      }); 
     }, 
    //to change good's full view after row deleting 
    loadComplete: function(data){ 
     var myGrid = $('#GridTable'), 
      selRowId = myGrid.jqGrid('getGridParam', 'selrow'), 
      celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId'); 
     $.ajax({ 
      url: "/Goods/DetailInfo", 
      type: "GET", 
      data: { id: celValue } 
     }) 
     .done(function (partialViewResult) { 
      $("#goodDetInfo").html(partialViewResult); 
     }); 
    }, 
    autowidth: true, 
    multiselect: false 
}).navGrid('#pager', { edit: false, add: true, del: true, search: false, refresh: true }, 
    { 
     // edit options 
     zIndex: 100, 
     url: '/Goods/Edit', 
     closeOnEscape: true, 
     closeAfterEdit: true, 
     recreateForm: true, 
     afterComplete: function (response) { 
      if (response.responseText) { 
       alert(response.responseText); 
      } 
      var myGrid = $('#GridTable'), 
      selRowId = myGrid.jqGrid('getGridParam', 'selrow'), 
      celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId'); 
      $.ajax({ 
       url: "/Goods/DetailInfo", 
       type: "GET", 
       data: { id: celValue } 
      }) 
      .done(function (partialViewResult) { 
       $("#goodDetInfo").html(partialViewResult); 
      }); 
     } 
    }, 
    { 
     // add options 
     zIndex: 100, 
     url: "/Goods/Create", 
     closeOnEscape: true, 
     closeAfterAdd: true, 

     afterComplete: function (response) { 
      if (response.responseText) { 
       alert(response.responseText); 
      } 
     } 
    }, 
    { 
     // delete options 
     zIndex: 100, 
     url: "/Goods/Delete", 
     closeOnEscape: true, 
     closeAfterDelete: true, 
     recreateForm: true, 
     msg: "Are you sure you want to delete this task?", 
     afterComplete: function (response) { 
      if (response.responseText) { 
       alert(response.responseText); 
      } 
     } 
    }); 

$('#GridTable').inlineNav('#pager', { 
    edit: true, 
    add: false, 
    del: false, 
    cancel: true, 
    editParams: { 
     keys: true, 
     afterSubmit: function (response) { 
      if (response.responseText) { 
       alert(response.responseText); 
      } 
      var myGrid = $('#GridTable'), 
      selRowId = myGrid.jqGrid('getGridParam', 'selrow'), 
      celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId'); 
      $.ajax({ 
       url: "/Goods/DetailInfo", 
       type: "GET", 
       data: { id: celValue } 
      }) 
      .done(function (partialViewResult) { 
       $("#goodDetInfo").html(partialViewResult); 
      }); 
     } 
    }, 
}); 

});

答えて

0

editParamsのパラメータとinlineNavのコールバック関数はhereです。必要なのは、afterSubmitの代わりにaftersavefuncまたはsuccessfuncであり、フォームの編集方法(hereを参照)にのみ存在します。 aftersavefuncまたはsuccessfuncコールバックのパラメータは、(saveRowのパラメータとして)hereを説明したが、パラメータがjqGridのバージョンに依存して、あなたが使用しているとjqGrid(free jqGrid、商用Guriddo jqGrid JSまたはバージョン< = 4.7の古いjqGridのフォークからされています)。私は無料のjqGridフォークを開発し、現在の(4.13.3)バージョンの無料jqGridを使用することをお勧めします。

関連する問題