views:

228

answers:

4

Is it possible to make it so that a jqGrid will have a width set to 100%? I understand that column widths must be an absolute pixel size, but I've yet to find anything for setting the width of the actual grid to a relative size. For instance, I want to set the width to 100%. Instead of 100% it seems to use an odd size of 450px. There is more horizontal room on the page, but with the columns width and such, it will make the container(of only the grid) horizontally scroll. Is there some way around this?

alt text

+1  A: 

It looks like this is not supported. According to the docs for setGridWidth:

Sets a new width to the grid dynamically. The parameters are: new_width is the new width in pixels...

The docs for the width option also do not mention being able to set width as a percentage.

That being said, you can use the autowidth feature or a similar technique to give the grid the correct initial width. Then follow the methods discussed in resize-jqgrid-when-browser-is-resized to ensure the grid is properly resized when the browser window is resized, which will simulate the effect of having 100% width.

Justin Ethier
A: 

You can try to fix the width of jqGrid with respect of a function which I described here http://stackoverflow.com/questions/2686043/correctly-calling-setgridwidth-on-a-jqgrid-inside-a-jqueryui-dialog/2696776#2696776

Oleg
A: 

You can't give width in percent, while if you want according to screen resolution then set as follows: var w = screen.width and then use this variable in width option of jqgrid.

Hope it will useful.

M Hussain
A: 

I ended up using the jqGrids.fluid extension to do this and it worked great.

Earlz