One of the nice feature that JQGrid provides is enabling auto height using setGridHeight("100%"). This feature works fine except if the "number of rows on the current page" is less than "rows per page" which is last page, since it sets height to "100%" the height of the page is suddenly reduced.
Here is the sample screenshots taken from JQGrid demo website (goto Advanced -> Resizing)
First Page :
Last Page :
You wouldn't want this to happen if you got some more content after the grid. So now here is how you can fix this :-
loadComplete: function(data) { var rcPage = jQuery('#invoicesGrid').getGridParam('reccount'); var rpPage = jQuery('#invoicesGrid').getGridParam('rowNum'); var rowHeight = $('#invoicesGrid .ui-row-ltr').eq(0).height(); if(rcPage < rpPage) { if(rowHeight){ var gridHeight = (rpPage * rowHeight); gridHeight += 10; //row header height jQuery('#invoicesGrid').setGridHeight(gridHeight); } } else { jQuery('#invoicesGrid').setGridHeight('100%'); } jQuery('#invoicesGrid').setGridParam('scrollOffset',0); }
Just hook up this code to your jqgrid and this should do the trick.
A computer once beat me at chess, but it was no match for me at kick boxing. Emo Philips
Great Article
ReplyDeleteASP.NET MVC Training
Online MVC Training
Online MVC Training India
Dot Net Training in Chennai
.Net Online Training
.net training online
Dot Net Online Training
C# Training