Monday, 28 July 2014

Resize jqGrid based on number of rows 0

To resize grid based on number of rows, Just we need to say this in configuration settings of jqGrid.

Yes. we need to set like this below.

$("#mygrid").jqGrid({
    ...,
    ...,
    ...,
    height:'auto',
    ...,
    ...
});
 
simply set height property to auto.

How it actually works?

This height configuration for the body of the grid. Our grid table is actually placed within the body of the grid. We can get that body of the grid by this selector ".ui-jqgrid-bdiv".

So, If we not set height property in jqGrid configuration, It will take the default height to 150px. If we send one record to jqGrid, it will show like this below,


If we set height property to auto in jqGrid configuration settings, and we are sending only one record to grid. It will showing the grid like below,


So, If we sending more than 20 records, and we set our grid limit to 20 per page. So, Grid showing correctly showing 20 records in first page. See the below image.


Have any doubt? Feel free to comment here!!!


0 comments:

Post a Comment