2013-08-01 89 views
0

好吧,所以我想添加刪除/更新/添加功能到我的網格。目前的問題是,當我點擊提交刪除確認彈出Url有我不想要的額外參數。jqGrid刪除附加刪除URL的附加參數

例:http://xxx.xxx/product/DeleteProduct?productId=&oper=del&id=2000

我希望它看起來像: http://xxx.xxx/product/DeleteProduct?productId=2000

如何刪除 「& OPER =德爾& ID =」。

感謝您的任何幫助。下面的代碼。

<div id="tabs-2"> 
<script type="text/javascript"> 
     $(document).ready(function() { 
      jQuery("#productTable").jqGrid({ 
       url: 'http://xxx.xxx/product/GetAllProducts', 
       mtype: 'GET', 
       datatype: 'json', 
       height: 250, 
       width: 900, 
       pgbuttons: false, pgtext: null, viewrecords: false, rowList: [], 
       rowNum:-1, 
       pager: '#productPager', 
       viewrecords: true, 
       colNames: ['Id', 'Active', 'Description', 'Features', 'Name', 'Specification', 'ThumbNail', 'View Image', 'Solution Id', 'Search Type', 'Section', 'Section Search'], 
       colModel: [ 
       { name: 'Id', index: 'Id', width: 60, sortable: false,align:"center", editable: false }, 
       { name: 'active', index: 'active', width: 90, sortable: false, align:"center", editable: true }, 
       { name: 'description', index: 'description', width: 90, sortable: false, editable: true }, 
       { name: 'features', index: 'features', width: 100, sortable: false, editable: true }, 
       { name: 'name', index: 'name', width: 80, sortable: false, editable: true }, 
       { name: 'specification', index: 'specification', width: 100, height:40, sortable: false, editable: true, edittype:'textarea',editoptions: { 
        rows:'3',cols:'20', dataInit: function (domElem) { 
         $(domElem).addClass("editable"); 
        }}}, 
       { name: 'thumbNail', index: 'thumbNail', width: 100, sortable: false, editable: true }, 
       { name: 'viewImage', index: 'viewImage', width: 100, sortable: false, editable: true }, 
       { name: 'SolutionId', index: 'SolutionId', width: 100, sortable: false, align:"center", editable: true }, 
       { name: 'searchType', index: 'searchType', width: 100, sortable: false, align:"center", editable: true }, 
       { name: 'section', index: 'section', width: 100, sortable: false, align:"center", editable: true }, 
       { name: 'sectionSearch', index: 'sectionSearch', width: 100, sortable: false, align:"center", editable: true }, 
       ], 
       jsonReader: { 
        root: 'resultObject', 
        id: 'Id', 
        repeatitems: false, 
        page: function (obj) { return 1; }, 
        total: function (obj) { return 1; }, 
        records: function (obj) { return obj.resultObject.length } 
       }, 
      }); 
      jQuery("#productTable").jqGrid('navGrid', '#productPager', { edit: false, add: false, del: true, search: false, refresh: false }, 
      // Edit options 
      {}, 
      // Add options 
      {}, 
      //del options 
      { 
       mtype: 'GET', 
       url: 'http://xxx.xxx/product/DeleteProduct?productId=', 
       onclickSubmit: function (postdata) { 
       alert('in onclickSubmit: postdata=' + postdata); 
       return {}; 
      }, 
      reloadAfterSubmit: true, 
      closeOnEscape: true, 
      bottominfo: "Fields marked with (*) are required." 
      } 
     ); 
    }); 
</script> 

<table id="productTable"></table> 
<div id="productPager"></div> 
</div> 

回答

0

想通了!不得不使用serializeEditData:

jQuery("#productTable").jqGrid('navGrid', '#productPager', { edit: true, add: true, del: true, search: false, refresh: true }, 
      // edit options 
      { mtype: 'GET', 
       onclickSubmit: function(rp_ge, postdata) { 
       rp_ge.url = 'xxx.xxx/product/UpdateProduct?productId='+ postdata.productTable_id + '&active=' + postdata.active + '&description=' + postdata.description + '&features=' + postdata.features + '&name=' + postdata.name + '&specification=' + postdata.specification + '&thumbNail=' + postdata.thumbNail + '&viewImage=' + postdata.viewImage + '&solutionId=' + postdata.SolutionId + '&searchType=' + postdata.searchType + '&section=' + postdata.section + '&sectionSearch=' + postdata.sectionSearch; 
      }, 
       serializeEditData: function (postdata) { return ""; }, 
       reloadAfterSubmit: true, 
       closeOnEscape: true, 
       closeAfterEdit: true 
      }, 
      // add options 
      { 
      mtype: 'GET', 
       onclickSubmit: function(rp_ge, postdata) { 
       rp_ge.url = 'http://xxx.xxx/product/AddProduct?productId='+ postdata.Id + '&active=' + postdata.active + '&description=' + postdata.description + '&features=' + postdata.features + '&name=' + postdata.name + '&specification=' + postdata.specification + '&thumbNail=' + postdata.thumbNail + '&viewImage=' + postdata.viewImage + '&solutionId=' + postdata.SolutionId + '&searchType=' + postdata.searchType + '&section=' + postdata.section + '&sectionSearch=' + postdata.sectionSearch; 
      }, 
       serializeEditData: function (postdata) { return ""; }, 
       reloadAfterSubmit: true, 
       closeOnEscape: true, 
       closeAfterAdd: true 

      }, 
      //del options 
      { 
       mtype: 'GET', 
       onclickSubmit: function(rp_ge, postdata) { 
       rp_ge.url = 'http://xxx.xxx/product/DeleteProduct?productId='+ postdata; 
      }, 
       serializeDelData: function (postdata) { return ""; }, 
       reloadAfterSubmit: true, 
       closeOnEscape: true 
      } 
     ); 

});