Skip to content Skip to sidebar Skip to footer

How To Hide And Show Custom Buttons In Jqgrid By Using "reccount"

I'm trying to implement a custom button on a jqGrid with hide and show functionalities. I basically want to show the button if the grid is empty otherwise show. I have implemented

Solution 1:

The problem with your code is that the grid is loaded asynchronously, which means your call to reccount can happen before the grid is populated, so it returns 0 even though the grid is filled with data a moment later.

One solution is to dynamically hide your button based on whether any data was populated by a server request. For example:

$("#sessioninfoGrid"+row_id).jqGrid({
    ...
    loadComplete: function() {
      var count = jQuery("#sessioninfoGrid"+row_id)
                      .jqGrid('getGridParam','reccount');
      if (count === 0){
          jQuery('button[title="Load Session Infos"]').hide();
      } else {
          jQuery('button[title="Load Session Infos"]').show();
      }
    },
    ...

Post a Comment for "How To Hide And Show Custom Buttons In Jqgrid By Using "reccount""