• <i id='MWvUS'><tr id='MWvUS'><dt id='MWvUS'><q id='MWvUS'><span id='MWvUS'><b id='MWvUS'><form id='MWvUS'><ins id='MWvUS'></ins><ul id='MWvUS'></ul><sub id='MWvUS'></sub></form><legend id='MWvUS'></legend><bdo id='MWvUS'><pre id='MWvUS'><center id='MWvUS'></center></pre></bdo></b><th id='MWvUS'></th></span></q></dt></tr></i><div id='MWvUS'><tfoot id='MWvUS'></tfoot><dl id='MWvUS'><fieldset id='MWvUS'></fieldset></dl></div>
      <legend id='MWvUS'><style id='MWvUS'><dir id='MWvUS'><q id='MWvUS'></q></dir></style></legend>

    1. <small id='MWvUS'></small><noframes id='MWvUS'>

      1. <tfoot id='MWvUS'></tfoot>
          <bdo id='MWvUS'></bdo><ul id='MWvUS'></ul>

        jqGrid 删除一行

        时间:2023-08-26
          • <legend id='6Yz2s'><style id='6Yz2s'><dir id='6Yz2s'><q id='6Yz2s'></q></dir></style></legend>

              <tfoot id='6Yz2s'></tfoot>
              <i id='6Yz2s'><tr id='6Yz2s'><dt id='6Yz2s'><q id='6Yz2s'><span id='6Yz2s'><b id='6Yz2s'><form id='6Yz2s'><ins id='6Yz2s'></ins><ul id='6Yz2s'></ul><sub id='6Yz2s'></sub></form><legend id='6Yz2s'></legend><bdo id='6Yz2s'><pre id='6Yz2s'><center id='6Yz2s'></center></pre></bdo></b><th id='6Yz2s'></th></span></q></dt></tr></i><div id='6Yz2s'><tfoot id='6Yz2s'></tfoot><dl id='6Yz2s'><fieldset id='6Yz2s'></fieldset></dl></div>

                  <tbody id='6Yz2s'></tbody>
                  <bdo id='6Yz2s'></bdo><ul id='6Yz2s'></ul>
                • <small id='6Yz2s'></small><noframes id='6Yz2s'>

                  本文介绍了jqGrid 删除一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经创建了我的网格,并希望使用网格的默认行为来删除一行.

                  I have created my grid and would like to use default behaviour of the grid to delete a row.

                  这是我的网格设置代码:

                  This is my grid setup code:

                  $("#grid").jqGrid('navGrid', '#grid_pager',
                      { add: true, addtitle: 'Add Customer', 
                        edit: true, edittitle: 'Edit Customer',
                        del: true, deltitle: 'Delete Customer', 
                        refresh: true, refreshtitle: 'Refresh data',
                        search: true, searchtitle: 'Advanced search filters', 
                        addfunc: addReferent, editfunc: editReferent
                      },
                      {}, // default settings for edit
                      {}, // default settings for add
                      { // define settings for Delete 
                          mtype: "post", 
                          reloadAfterSubmit: true,
                          url: wsBaseUrl + 'CustomerService.asmx/DeleteCustomer',
                          resize: false,
                          serializeDelData: function(postdata) {
                              return JSON.stringify({ customerID: postdata.id });
                          }
                      },
                      { // define settings for search
                          closeOnEscape: true, multipleSearch: true, closeAfterSearch: true 
                      }, 
                      {}
                  );
                  

                  这是在服务器上定义的网络服务方法

                  and this is the web service method defined on the server

                  [WebMethod]
                  public OperationResult Deletecustomer(string customerID)
                  {
                  }
                  

                  但不幸的是,当我单击删除按钮并在确认窗口上单击确定时,我收到一条错误消息 404.如下图所示

                  but unfortunately when I click the delete button and click ok on the confirm window I get an error saying 404. as in the following picture

                  我做错了什么?

                  我已将以下代码添加到我的 jqGrid 初始化中

                  I have added the following code to my jqGrid Initialization

                  // Set defaults value for jqGrid
                  $.jgrid.defaults = $.extend($.jgrid.defaults, {
                      mtype: 'post',
                      datatype: 'json',
                      jsonReader: {
                          root: "d.Rows",
                          page: "d.Page",
                          total: "d.Total",
                          records: "d.Records",
                          repeatitems: false,
                          userdata: "d.UserData",
                          id: "Id"
                      },
                      ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
                      serializeGridData: function (postData) {
                          return JSON.stringify(postData);
                      },
                      ajaxDelOptions: { contentType: 'application/json; charset=utf-8' },
                      serializeDelData: function (postData) {
                          return JSON.stringify(postData);
                      },
                      loadui: "block",
                      multiboxonly: true,
                      rowNum: 25,
                      rowList: [25, 50, 100],
                      altRows: true,
                      altclass: 'ui-priority-secondary',
                      autoencode: true,
                      autowidth: true,
                      rownumbers: true,
                      rownumWidth: 30,
                      gridview: true,
                      hoverrows: true,
                      viewrecords: true
                  });
                  

                  但我仍然遇到同样的错误...

                  but I still get the same error...

                  推荐答案

                  也许你应该只使用 JSON.stringify (来自 json2.js) 在 serializeDelData 内.您没有发布您需要删除的网络方法 DeleteCustomer 的原型,但您的问题可能可以通过以下代码解决:

                  Probably you should just use JSON.stringify (from json2.js) inside of serializeDelData. You don't posted the prototype of your web method DeleteCustomer which you need to delete, but probably your problem could be fixed with the following code:

                  serializeDelData: function(postdata) {
                      return JSON.stringify({customerID: postdata.id});
                  }
                  

                  使用 ASMX 服务时的另一个常见问题.可能需要定义调用的 Web 方法的所有参数(参见 这里一个例子).

                  One more common problem in case of the usage of ASMX services. It can be need to define all parameters of the web method called (see here an example).

                  ajaxDelOptions: { contentType: "application/json" } 参数的用法也大多是必需的.

                  The usage of ajaxDelOptions: { contentType: "application/json" } parameter is also required mostly.

                  使用 Fiddler 或 Firebug 来捕获和分析 HTTP 流量.

                  It can be helpful to use Fiddler or Firebug to capture and analyse the HTTP traffic.

                  这篇关于jqGrid 删除一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Ajax 调用加载 Asp.Net 中继器的 JQuery 数据表插 下一篇:将日期从波斯语转换为公历

                  相关文章

                  最新文章

                  <i id='JmkC9'><tr id='JmkC9'><dt id='JmkC9'><q id='JmkC9'><span id='JmkC9'><b id='JmkC9'><form id='JmkC9'><ins id='JmkC9'></ins><ul id='JmkC9'></ul><sub id='JmkC9'></sub></form><legend id='JmkC9'></legend><bdo id='JmkC9'><pre id='JmkC9'><center id='JmkC9'></center></pre></bdo></b><th id='JmkC9'></th></span></q></dt></tr></i><div id='JmkC9'><tfoot id='JmkC9'></tfoot><dl id='JmkC9'><fieldset id='JmkC9'></fieldset></dl></div>
                  <legend id='JmkC9'><style id='JmkC9'><dir id='JmkC9'><q id='JmkC9'></q></dir></style></legend>

                  <small id='JmkC9'></small><noframes id='JmkC9'>

                    <tfoot id='JmkC9'></tfoot>

                        <bdo id='JmkC9'></bdo><ul id='JmkC9'></ul>