0

好的,所以我正在尝试向我的网格添加删除/更新/添加功能。当前的问题是当我在删除确认弹出窗口中单击提交时,Url 有我不想要的额外参数。

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

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

如何删除“&oper=del&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>
4

1 回答 1

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
            }   
        );

});
于 2013-08-02T18:49:11.823 回答