Resize jqGrid based on number of rows andrey понедельник, 28 июля 2014 г. No Comment

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!!!


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!!!


by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment