title: How to hide and show custom buttons in jqGrid by using "reccount"
body: <p>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.</p>
  
  <p>I have implemented it with the "reccount" method from jqGrid to test if the grid is empty. However i'm not sure if i'm doing it right.  </p>
  
  <p>to the end of the code is where i declared the reccount. see "var count". </p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>$("#sessioninfoGrid"+row_id).jqGrid({
      url:'/starburst/sessioninfoes/jsonlistbylectureoutline/'+row_id,
      datatype: "json",
      colNames: ['Session No.','Date','Start Time','End Time','Duration/Hours','Session Type','Topic','Room'],
      colModel: [
          {name:'sessionNumber',index:'SessionNumber', width:40, formoptions:{elmprefix:'(*) '}, editrules:{required:true}, editable:true, edittype: 'text'},
          {name:'sessionDate',index:'sessionDate', width:100, formoptions:{elmprefix:'(*) '}, editrules:{required:true}, editable:true, edittype: 'text',               
              editoptions: {
                  dataInit: function(element) {
                      $(element).datepicker({dateFormat: 'DD, MM dd, yy'})
                  }
              } 
          },
          {name:'starttime',index:'starttime', width:50, formoptions:{elmprefix:'(*) '}, editrules:{required:true}, editable:true, edittype: 'text'
  
          },
          {name:'endtime',index:'endtime', width:50, formoptions:{elmprefix:'(*) '}, editrules:{required:true}, editable:true, edittype: 'text'
  
          },
          {name:'durationPerSession',index:'durationPerSession', width:50, formoptions:{elmprefix:'(*) '}, editrules:{required:true}, editable:true, edittype: 'text'
          },
          {name:'sessionType',index:'sessionType', width:50, formoptions:{elmprefix:'(*) '}, editable:true, editrules:{required:true}, edittype: 'select',
              editoptions:{value:{}}
          },
          {name:'topic',index:'topic', width:200, formoptions:{elmprefix:'(*) '}, editable:true, editrules:{required:true}, edittype: 'text',
              editoptions: {
                  dataInit: function(element) {
                      $(element).width(300)
                  }
              }
          },
          {name:'room',index:'room', width:35}
      ],
      rowNum:10,
      autowidth: true,
      pager: sessioninfoPager_id,
      sortname: 'id', 
      viewrecords: true, 
      sortorder: "desc",
      editurl: '&lt;c:url value="/sessioninfoes/update"/&gt;',
      caption:"Session Info",
      emptyrecords: "Empty Records"                           
  
  });
  $("#sessioninfoGrid"+row_id).jqGrid('navGrid',"#"+sessioninfoPager_id,{edit:false,add:false,del:false,search:true},{ },{ },{ },
  { 
      sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'],
      closeOnEscape: true, 
      multipleSearch: true, 
      closeAfterSearch: true 
  }
  );
  $("#sessioninfoGrid"+row_id).navButtonAdd("#"+sessioninfoPager_id,
  {   
      caption:"Add", 
      buttonicon:"ui-icon-plus", 
      onClickButton: addSessionInfoRow,
      position: "last", 
      title:"Add New Session Info", 
      cursor: "pointer"
  } 
  ); 
  
  $("#sessioninfoGrid"+row_id).navButtonAdd("#"+sessioninfoPager_id,
  {   
      caption:"Edit", 
      buttonicon:"ui-icon-pencil", 
      onClickButton: editSessionInfoRow,
      position: "last", 
      title:"Edit Session Info", 
      cursor: "pointer"
  } 
  );
  
  var count= $("#sessioninfoGrid"+row_id).jqGrid('getGridParam','reccount');
  if (count == 0){
      $("#sessioninfoGrid"+row_id).navButtonAdd("#"+sessioninfoPager_id,
          {   
              caption:"Load Sessions",
              buttonicon:"ui-icon-plusthick", 
              onClickButton: function(){                                   
                  $.post('&lt;c:url value="/sessioninfoes/autocreate/"/&gt;'+row_id,function(data){
                      $("#sessioninfoGrid"+row_id).trigger("reloadGrid");
                  });                                  
              },
              position: "last", 
              title:"Load Session Infos", 
              cursor: "pointer"
          } 
      );
  }
  </code></pre>