简体   繁体   English

在Kendo Grid的Ajax调用期间如何关闭Ajax全局设置

[英]How to turn off ajax global setting during kendo grid's ajax call

In MVC 5 in _layout page i have .ajaxStart & .ajaxStop event to show the busy indicator. 在_layout页面的MVC 5中,我具有.ajaxStart和.ajaxStop事件以显示忙碌指示器。

<body>
        <script type="text/javascript">
        $(document).ajaxStart(function (e) {            
           $("#loading-div-background");

           $("#loading-div-background").show();
        });

        $(document).ajaxStop(function (e) {

            $("#loading-div-background").hide();
        });
   </script>
</body>

We are using kendo grid which makes the ajax request to populate the grid. 我们使用的是kendo grid,它发出ajax请求来填充网格。 Kendo has its own busy indicator. 剑道有自己的忙碌指示器。 We would like to use kendo's busy indicator and turn off the gloabal indicator in certain cases. 在某些情况下,我们想使用剑道的忙碌指示器并关闭角标指示器。 Usually we can turn off the global by setting the global to false when we make ajax call. 通常,在进行ajax调用时,可以通过将global设置为false来关闭global。

$.ajax({ global: false }) $ .ajax({global:false})

However with kendo, we are not explicitly making the ajax call How do i set global to false here. 但是,对于kendo,我们没有明确地进行ajax调用。如何在此处将global设置为false。

I think you should try for tricky. 我认为您应该尝试棘手。 You can use one global variable and use it as flag in your ajaxStart method. 您可以使用一个全局变量,并将其用作ajaxStart方法中的标志。 Find suitable event from "http://demos.telerik.com/kendo-ui/grid/events" “ http://demos.telerik.com/kendo-ui/grid/events”中找到合适的事件

On this event set your globle variable value to false. 在这种情况下,将您的全球变量值设置为false。

FOR EXAMPLE : 例如 :

var flag = true;
 function onDataBinding(arg) {
                   flag = false;
                }

$(document).ajaxStart(function (e) {
if(flag){$("#loading-div-background").show();}

        });

Make sure to maintain flag value in grid events. 确保在网格事件中保持标志值。

I found it 我找到了

var grid = $("#grid").data("kendoGrid");    
grid.dataSource.transport.options.read.global = false;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM