Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid and the autowidth option. How does it work?

Tags:

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?

like image 382
Lorenzo Avatar asked Oct 11 '10 12:10

Lorenzo


People also ask

How do you use jqGrid?

In this step, we are going to add jqGrid Script and CSS reference to index view. This script is added to project when we add jqGrid Grid from NuGet package. After adding Scripts and Css next we need to add table element for reserve the place where the grid should be created.

How is jqGrid width dynamically set?

You can set the new width of the column using two methods – setColProp and setGridWidth. This solution works, except that I needed to use "widthOrg" instead of "width" in the call to 'setColProp'.

What is colModel in jqGrid?

In a nutshell, colNames defines the names of your jqGrid columns on the page, and colModel specifies options for each column (name in the dataset, width, etc). The documentation has more information: colModel Array which describes the parameters of the columns. This is the most important part of the grid.


1 Answers

Solution: shrinkToFit: false

like image 81
Lorenzo Avatar answered Oct 12 '22 00:10

Lorenzo