JqGrid - not submit data message in grid?

If there was no data in our search, we use a callback loadCompleteto print a message to the user to indicate that there is no data. Is there a way to configure jqGrid to print a β€œno data” message in the grid? We are currently printing it in divover the grid, but want it to be in the real grid.

+2
source share
3 answers

jqGrid displays the message "There are no entries to view" ( $.jgrid.defaults.emptyrecords) only at the end of the pager area and only if all subsequent ones are executed

  • you define a pager
  • viewrecords: true
  • the current number of records ( reccountparameter) is 0.

- "" ( ). , , div, , / loadComplete.

+8

: , , jqGrid i.e. navGrid. <DIV> , jqGrid - .

: . , . HTML - loadComplete, , " ".

HTML:

<pre>
  <div class="cols jsGridOuter" style="position:relative;">
    <table id="mandateList" class="jsStretchGridWidth"><tr><td></td></tr></table>
    <div class="noResultsDiv gridNoRecords jstHidden">
      <span class="notice"><label>No records to show</label></span>
    </div>
    <div id="pagination"></div>
  </div>
</pre>

Java Script:

loadComplete: function() {
  if (j$(this).getGridParam("records")==0) 
  {
    j$('div#pagination').hide();
    if (j$('div.noResultsDiv').hasClass('jstHidden'))
    {
      j$('div.noResultsDiv').removeClass('jstHidden');
    }
  }
  else
  {
    j$('div#pagination').show();
    if (j$('div.noResultsDiv').length>0)
    {
      j$('div.noResultsDiv').addClass('jstHidden');
    }
  }
}
0

You can overwrite the html of the body table to display your message. Use this for this:

loadComplete: function() {
                if ($('#Grid').getGridParam('records') === 0) {
                    oldGrid = $('#GridIdb2 tbody').html();
                    $('#Grid tbody').html("<div style='padding:6px;background:#D8D8D8'>No records found</div>");
                }
                else
                    oldGrid = "";
             }

Use oldgrid var as a helper to save what jqgrid had before changing; Before submitting a new search, set the old value:

if(oldGrid!=""){
    $("#Grid tbody").html(oldGrid);
}
0
source

Source: https://habr.com/ru/post/1779549/


All Articles