jqGrid trigger “Loading…” overlay

后端 未结 9 1807
孤独总比滥情好
孤独总比滥情好 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 08:39

    If you are searching for something like DisplayLoadingMessage() function. It does not exist in jqGrid. You can only set the loadui option of jqGrid to enable (default), disable or block. I personally prefer block. (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options). But I think it is not what you wanted.

    The only thing which you can do, if you like the "Loading..." message from jqGrid, is to make the same one. I'll explain here what jqGrid does to display this message: Two hidden divs will be created. If you have a grid with id=list, this divs will look like following:

    <div style="display: none" id="lui_list"
         class="ui-widget-overlay jqgrid-overlay"></div>
    <div style="display: none" id="load_list"
         class="loading ui-state-default ui-state-active">Loading...</div>
    

    where the text "Loading..." or "Lädt..." (in German) comes from $.jgrid.defaults.loadtext. The ids of divs will be constructed from the "lui_" or "load_" prefix and grid id ("list"). Before sending ajax request jqGrid makes one or two of this divs visible. It calls jQuery.show() function for the second div (id="load_list") if loadui option is enable. If loadui option is block, however, then both divs (id="lui_list" and id="load_list") will be shown with respect of .show() function. After the end of ajax request .hide() jQuery function will be called for one or two divs. It's all.

    You will find the definition of all css classes in ui.jqgrid.css or jquery-ui-1.8.custom.css.

    Now you have enough information to reproduce jqGrid "Loading..." message, but if I were you I would think one more time whether you really want to do this or whether the jQuery blockUI plugin is better for your goals.

    0 讨论(0)
  • 2020-12-03 08:49

    its is worling with $('div.loading').show(); This is also useful even other components

    $('#editDiv').dialog({
                modal : true,
                width : 'auto',
                height : 'auto',
                buttons : {
                    Ok : function() {
                        //Call Action to read wo and 
                         **$('div.loading').show();**
    
                        var status = call(...)
                        if(status){
                            $.ajax({
                                type : "POST",
                                url : "./test",
                                data : {
                                    ...
                                },
                                async : false,
                                success : function(data) {
    
                                    retVal = true;
                                },
                                error : function(xhr, status) {
    
    
                                    retVal = false;
                                }
                            });
                        }
                        if (retVal == true) {
                            retVal = true;
                            $(this).dialog('close');
                        }
                        **$('div.loading').hide();**
                    },
                    Cancel : function() {
                        retVal = false;
                        $(this).dialog('close');
                    }
    
                }
            });
    
    0 讨论(0)
  • 2020-12-03 08:51

    Simple, to show it:

    $("#myGrid").closest(".ui-jqgrid").find('.loading').show();
    

    Then to hide it again

    $("#myGrid").closest(".ui-jqgrid").find('.loading').hide();
    
    0 讨论(0)
  • 2020-12-03 08:54

    The style to override is [.ui-jqgrid .loading].

    0 讨论(0)
  • 2020-12-03 08:56

    I use

            $('.loading').show();
            $('.loading').hide();
    

    It works fine without creating any new divs

    0 讨论(0)
  • 2020-12-03 08:59

    As mentioned by @Oleg the jQuery Block UI have lots of good features during developing an ajax base applications. With it you can block whole UI or a specific element called element Block

    For the jqGrid you can put your grid in a div (sampleGrid) and then block the grid as:

    $.extend($.jgrid.defaults, {
        ajaxGridOptions : {
            beforeSend: function(xhr) {
                $("#sampleGrid").block();
            },
            complete: function(xhr) {
                $("#sampleGrid").unblock();
            },
            error: function(jqXHR, textStatus, errorThrown) {
                $("#sampleGrid").unblock();
            }
        }
    });
    
    0 讨论(0)
提交回复
热议问题