jqGrid and the autowidth option. How does it work?
Asked Answered
L

2

23

I am using jqGrid with the autowidth option set to true.

According to the documentation:

When set to true, the grid width is recalculated automatically to the width of the parent element. This is done only initially when the grid is created. In order to resize the grid when the parent element changes width you should apply custom code and use a setGridWidth method for this purpose

This makes the grid occupy all the width available in the parent element. Another effect of this property is that every column shrinks to fit the width available.

This works very well. However, I have one page where don't want the columns to shrink to fit the grid width, but they should occupy the space that I set within the colModel for them.

How can I achieve this?

Lost answered 11/10, 2010 at 12:47 Comment(4)
Do you mean on the grid table element?Lost
Found the solution: I did not realized that the shrinkToFit option had a default value of true. I have set it to false and everything is ok now...Lost
No, I meant on the grid.Oppression
Ok! anyway I have found the solution. As I wrote in the previous comment I left the autowidth option set to true and I have set the shrinkToFit option to false. thanks for you help :)Lost
L
27

Solution: shrinkToFit: false

Lost answered 3/11, 2010 at 23:0 Comment(1)
How can do it vs Subgrid?Teraterai
I
12

set

autowidth=true, shrinkToFit=false

this setting will make width of jqgrid frame equal the parent ( usually equal the width of browser ) ; and column width equal the width defined in colModel ; unfornatelly jqgrid 4.3 donot give an simple way by setting a property to auto fit/resize the column width basing on width of the content ( text in cell );

default in jqgrid :

autowidth=false, shrinkToFit=true

please see the three properties of options of jqgrid in jqgrid option wiki;

autowidth

shrinkToFit

width

and property of colModel in jqgrid colModel wiki

width

fixed

I think the priority for jqgrid frame width is *jqgrid frame autowidth > jqgrid frame width > sum of column width *

the priority for column width is colmodel fixed > jqgrid frame shrinkToFit > colmodel width

Imogene answered 15/5, 2013 at 5:52 Comment(1)
autowidth: true, shrinkToFit: false! colon ' : ' sign instead of equals ' = ' signCaroleecarolin

© 2022 - 2024 — McMap. All rights reserved.