2016-05-27 2 views
0

У меня есть jqgrid, который отправляет данные строки другому представлению (MVC4) при выборе строки. Но когда я редактирую информацию о строке (я использую встроенное редактирование), это представление не изменяется. И я не могу найти событие, которое происходит после встроенного редактирования. Это js, что я должен изменить, чтобы изменить свое представление после редактирования строки?Событие, которое происходит после inline edit

$(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. Вероятно, вам нужно aftersavefunc или successfunc вместо afterSubmit, которые существуют только в форме метода редактирования (см. here). Параметры aftersavefunc или successfunc обратных вызовов описаны here (как параметры saveRow), но параметры зависят от версии jqGrid, который вы используете, и от развилки jqGrid (free jqGrid, коммерческого Guriddo jqGrid JS или старого jqGrid в версии < = 4,7). Я разрабатываю бесплатную вилку jqGrid, и я бы порекомендовал вам использовать текущую (4.13.3) версию бесплатного jqGrid.

Смежные вопросы