<legend id='JaD2o'><style id='JaD2o'><dir id='JaD2o'><q id='JaD2o'></q></dir></style></legend>

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

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

    2. <tfoot id='JaD2o'></tfoot>

        <bdo id='JaD2o'></bdo><ul id='JaD2o'></ul>
      1. 如何向我的 jqgrid 添加取消按钮?

        How do I add a cancel button to my jqgrid?(如何向我的 jqgrid 添加取消按钮?)

          <tfoot id='jyAyz'></tfoot>

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

              <tbody id='jyAyz'></tbody>
            <legend id='jyAyz'><style id='jyAyz'><dir id='jyAyz'><q id='jyAyz'></q></dir></style></legend>
              1. <small id='jyAyz'></small><noframes id='jyAyz'>

                <i id='jyAyz'><tr id='jyAyz'><dt id='jyAyz'><q id='jyAyz'><span id='jyAyz'><b id='jyAyz'><form id='jyAyz'><ins id='jyAyz'></ins><ul id='jyAyz'></ul><sub id='jyAyz'></sub></form><legend id='jyAyz'></legend><bdo id='jyAyz'><pre id='jyAyz'><center id='jyAyz'></center></pre></bdo></b><th id='jyAyz'></th></span></q></dt></tr></i><div id='jyAyz'><tfoot id='jyAyz'></tfoot><dl id='jyAyz'><fieldset id='jyAyz'></fieldset></dl></div>
                • 本文介绍了如何向我的 jqgrid 添加取消按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的网站上有一个 jqgrid(版本 3.5.3),它通过对 Web 服务的 ajax 调用获取结果.通常查询很复杂,加载结果需要几秒钟.在加载时,用户会看到一个框 [Loading...].

                  I've got a jqgrid (version 3.5.3) on my site which gets its results from an ajax call to a web service. Often the query is complicated and it takes a few seconds to load the result. While it is loading the user sees a box [Loading...].

                  如果用户意识到他们正在搜索错误的东西,客户端会要求在网格中添加一个取消按钮,这将:

                  In case the users realise they're searching for the wrong thing, the client has asked to add a cancel button to the grid, which would:

                  1. 让网格忘记它刚刚请求的数据
                  2. 保留先前搜索已加载的结果

                  似乎没有为此内置任何东西,所以我可能正在寻找一些技巧来实现这一点.

                  There doesn't seem to be anything built in for this, so I'm probably looking for a bit of a hack to achieve this.

                  有什么想法吗?

                  推荐答案

                  这是我们的解决方案,与 Oleg 的非常相似,主要区别在于我们跟踪 XHR 列表以确保清理所有请求

                  Here's our solution, which is very similar to Oleg's, the main difference is that we keep track of a list of XHRs to make sure we clean all requests up

                  var handlerUrl = '';
                  
                  jQuery(document).ready(function() {
                      var xhrList = [];
                  
                      var beforeSendHandler = function() {
                  
                          var cancelPendingRequests = function() {
                              jQuery.each(xhrList, function() { this.abort(); });
                              xhrList = [];
                              return false;
                          };
                  
                          var hideLoadingUI = function() {
                              $(this).hide();
                              $("#load_list").hide();
                          };
                  
                          cancelPendingRequests();
                  
                          $("#load_list").show();
                  
                  // some faffing around to ensure we only show one cancel button at a time
                          if (jQuery("#cancelrequest").length == 0) {
                              jQuery(".ui-jqgrid-titlebar").append(jQuery("<button   id='cancelrequest'>Cancel</button>").click(cancelPendingRequests).click(hideLoadingUI));
                          } else {
                              jQuery("#cancelrequest").show();
                          };  
                      }
                  
                  
                      jQuery("#list").jqGrid({
                          datatype: function(postdata) {
                  
                              GetSearchCriteria(); //needed for the grid's filtering
                  
                              var xhr = $.ajax({
                                  //we override the beforeSend so we can get at the XHRs, but this means we have to implement the default behaviour, like showing the loading message ourselves
                                  beforeSend: beforeSendHandler,
                                  dataType: "xml",
                                  data: postdata,
                                  success: function(xmlDoc) {
                                      //
                                      jQuery("#cancelrequest").hide();
                                      $("#load_list").hide();
                                      jQuery("#list")[0].addXmlData(xmlDoc);
                                      xhrList = [];
                                  }
                  

                  ...

                  这篇关于如何向我的 jqgrid 添加取消按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How to detect window size and then do something with jquery switch statement(如何检测窗口大小然后用 jquery switch 语句做一些事情)
                  jquery Using ranges in switch cases?(jquery 在切换案例中使用范围?)
                  switch statement in Jquery and List(Jquery 和 List 中的 switch 语句)
                  Switch-Case for strings in Javascript not working as expected(Javascript 中字符串的 Switch-Case 未按预期工作)
                  Switch case with conditions(带条件的开关盒)
                  <tfoot id='Bn1v5'></tfoot>
                  <legend id='Bn1v5'><style id='Bn1v5'><dir id='Bn1v5'><q id='Bn1v5'></q></dir></style></legend>
                  <i id='Bn1v5'><tr id='Bn1v5'><dt id='Bn1v5'><q id='Bn1v5'><span id='Bn1v5'><b id='Bn1v5'><form id='Bn1v5'><ins id='Bn1v5'></ins><ul id='Bn1v5'></ul><sub id='Bn1v5'></sub></form><legend id='Bn1v5'></legend><bdo id='Bn1v5'><pre id='Bn1v5'><center id='Bn1v5'></center></pre></bdo></b><th id='Bn1v5'></th></span></q></dt></tr></i><div id='Bn1v5'><tfoot id='Bn1v5'></tfoot><dl id='Bn1v5'><fieldset id='Bn1v5'></fieldset></dl></div>
                • <small id='Bn1v5'></small><noframes id='Bn1v5'>

                          <tbody id='Bn1v5'></tbody>

                        • <bdo id='Bn1v5'></bdo><ul id='Bn1v5'></ul>