2

I'm not able to change the columns width in the latest jqGrid version (4.4.1).

In the 3.8.2 version I used this code to change columns width (and it works well):

grid options:

shrinkToFit = true;

I put the following code in the loadComplete section.

First of all I changed the columns width:

$("#gridId").jqGrid('setColProp',"colname",{width:new_width});

and then I changed the grid width

$("#gridId").jqGrid('setGridWidth', newGridWidth);

and the grid was properly rendered.

I already tried to use the 4.3.2 modified release:
JQGrid: Resize Grid Width After Column Resized
but with no success.

Community
  • 1
  • 1

2 Answers2

2

The solution proposed by Alberto still works for jqGrid 4.5.4 (the current version). However, a better solution was suggested here: you need to replace width: with widthOrg: in

$("#gridId").jqGrid('setColProp',"colname",{width:new_width});

The second solution also works for jqGrid 4.5.4.

Community
  • 1
  • 1
Alexey
  • 2,542
  • 4
  • 31
  • 53
1

I've found a bug into grid.base.js, if you apply this fix grid resizing with different columns width will works.

Into setGridWidth I've changed both lines:

cw = this.widthOrg;

width

cw = this.width;
Baby Groot
  • 4,637
  • 39
  • 52
  • 71