How to remove (or hide) the title bar in jqgrid?

I see you can add a top title bar and put a title using this code:

jQuery('#grid').setCaption("Title"); 

Anyway, if I already set the title to remove the title bar?

I tried this, but it just deletes the text (doesn't delete the whole title bar).

 jQuery('#grid').setCaption(""); 
+7
source share
2 answers

If you want to hurry, test

 $(".ui-jqgrid-titlebar").hide(); 

or if you have several grids, then hide the heading of the line $ ("# grid"), then do

 $("#gview_grid > .ui-jqgrid-titlebar").hide() 
+19
source

If you create a jqGrid without a title ( caption: "" ) and examine the grid with respect to the developer tools or with respect to Firebug, you will see a <div> with the class "ui-jqgrid-titlebar" having a <span> with the class "ui-jqgrid- title "and anchor with the class" ui-jqgrid-titlebar-close "as children:

 <div id="gbox_list" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all"> ... <div id="gview_list" class="ui-jqgrid-view"> <div style="display: none;" class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"> <a style="right: 0px;" class="ui-jqgrid-titlebar-close HeaderButton" role="link" href="javascript:void(0)"> <span class="ui-icon ui-icon-circle-triangle-n"></span> </a> <span class="ui-jqgrid-title"></span> </div> ... 

Thus, even you create a grid without a jqGrid header, create all the hidden elements in the title bar .

I looked at the jqGrid code where the signature is generated and can find the following snippet

 if(ts.p.caption) { ... $(".ui-jqgrid-titlebar-close",grid.cDiv).click( function(e){ ... } else {$(grid.cDiv).hide();} 

So, in order to have the same results as with the grid initialized with the caption: "" parameter, you can do the following

 var mygrid = jQuery('#list'), cDiv = mygrid[0].grid.cDiv; mygrid.setCaption(""); $("a.ui-jqgrid-titlebar-close",cDiv).unbind(); $(cDiv).hide(); 

You should disable the Minimize button only if you are sure that the grid will not have a caption later. Links took up less resources and did nothing for the hidden grid.

So Pravat Mask’s proposal to simply hide the headline is absolutely correct, and my research only confirms this.

+7
source

All Articles