jqGrid trigger “Loading…” overlay

后端 未结 9 1873
孤独总比滥情好
孤独总比滥情好 2020-12-03 08:24

Does anyone know how to trigger the stock jqGrid \"Loading...\" overlay that gets displayed when the grid is loading? I know that I can use a jquery plugin without much eff

9条回答
  •  盖世英雄少女心
    2020-12-03 09:01

    If you want to not block and not make use of the builtin ajax call to get the data

    datatype="local"

    you can extend the jqgrid functions like so:

    $.jgrid.extend({
        // Loading function
        loading: function (show) {
            if (show === undefined) {
                show = true;
            }
            // All elements of the jQuery object
            this.each(function () {
                if (!this.grid) return;
                // Find the main parent container at level 4
                // and display the loading element
                $(this).parents().eq(3).find(".loading").toggle(show);
            });
            return show;
        }
    });
    

    and then simple call

    $("#myGrid").loading(); 
    

    or

    $("#myGrid").loading(true); 
    

    to show loading on all your grids (of course changing the grid id per grid) or

    $("#myGrid").loading(false); 
    

    to hide the loading element, targeting specific grid in case you have multiple grids on the same page

提交回复
热议问题