简体   繁体   中英

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.

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

However with kendo, we are not explicitly making the ajax call How do i set global to false here.

I think you should try for tricky. You can use one global variable and use it as flag in your ajaxStart method. Find suitable event from "http://demos.telerik.com/kendo-ui/grid/events"

On this event set your globle variable value to 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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