Regarding free-jqgrid 4.9.2, does it automatically handle column width? No, then what's the proper way to handle this?
1) VIN & Year columns contain too much free spaces
2) Trim contains few records that are too long to fit into column's width (Such as 1993 Mitsubishi 3000GT 2 Dr VR-4 Turbo AWD Hatchback)
Also, does jqGrid have true/false "word wrap" setting somewhere?
Demo is found at link removed
Auto-width adjustment exist in free jqGrid starting with 4.8 version. Free jqGrid still not handle the width of all columns automatically. One need add some additional properties in
colModel
for the columns which width should be set based on the width on the most long content and to set some additional options.Your current code uses
width: 190
for the column'Vin'
and don't specifies anywidth
property for any other columns, so default valuewidth: 150
will be used. Additionally you usewidth: 1022
option of jqGrid and wrong optionautoWidth: true
(instead ofautowidth: true
) which will be ignored. It means that the width of the div (bDiv or body div) over the grid will be set to 1022px and the user can use horizontal scrollbar to see all columns.I would recommend you to read the wiki article. You can add
autoResizable: true
property to some specific columns or to usecmTemplate: { autoResizable: true }
to add the property in all columns. As the result the content of every cell of the grid will be wrapped in<span class="ui-jqgrid-cell-wrapper">...</span>
. It allows free jqGrid to get the exact width of content for all cells of the column and then calculate the max from the values. So the user can double-click on the column resizer (between the columns) to set the width to the best value. During the width calculation jqGrid the width of the column header with the width of sorting icon additionally to the width of the grid cells of the column. One can useautoResizing: { compact: true }
option to reduce the width of the columns which don't have visible sorting icon. The last common option isautoresizeOnLoad: true
which I would recommend you to use. It will set the width of the columns havingautoResizable: true
property to the best value.So I would recommend you to add the following option to your grid:
After that the width of column will looks much better.
If you prefer to wrap the text of some columns if it is too long then you can use CSS settings described in the old answer and set
maxColWidth
property ofautoResizing
of the column (incolModel
) or global settingmaxColWidth
ofautoResizing
option of the grid to the max width of the column. More long text will be wrapped.