Below mentioned function will help you dynamically resize width of jqGrid according to width of the currently resized browser window.
Function:
/** * Function for resize the grid according to the width of the resized window * @param string grid_id - jqGrid id used in current page * @param string div_id - parent div_id according to whom it will need to resize * @param string width - width of the grid that has been set during initialize the grid setup * @returns void */ function resizeJqGridWidth(grid_id, div_id, width) { $(window).bind('resize', function() { $('#' + grid_id).setGridWidth(width, true); //Back to original width $('#' + grid_id).setGridWidth($('#' + div_id).width(), true); //Resized to new width as per window }).trigger('resize'); }
Detail:
setGridWidth(new_width, shrink): Sets a new width to the grid dynamically.
new_width: It will be the new width (pixel).
shrink (default true) :
true -> It will allow to resize columns with in the grid according to the currently resized jqGrid width.
false -> It will append additional blank column at the end of jqGrid, if currently resized width of jqGrid will exceed its setup jqGrid width.