0

I'm trying to get my jqGrid to resize automatically when the window is resized. And I'm using jQuery UI.layout. I've looked at the following links: make-jqgrid-fill-its-container and resize-jqgrid-when-browser-is-resized. But no matter what I do, the grid won't resize. If the width of the grid is 900, and I force it to 600, it stays at 900. It's like the request to change the width is just being ignored. I have autowidth: true and I've played around with forceFit and shrinkToFit values. But nothing is working.

Any advice is greatly appreciated. Thank you.

Update: It seems like the code used to reference the grid:

  var gridId = $(this).attr('id');
  $('#' + gridId).setGridWidth(paneState.innerWidth - 2);

wasn't actually getting the grid. In the jqGrid src, this.grid was always undefined. When I passed in the actual name of my grid, list, it worked. Now I just need to get the correct name that the function wants.

Community
  • 1
  • 1
DrZ
  • 181
  • 5
  • 22

1 Answers1

1

To set the width of the jqGrid, I'm using the following line of code without issue:

$('#myGrid').jqGrid('setGridWidth', newWidth);

myGrid corresponds to the id of the HTML table that is used by jqGrid.

RoccoC5
  • 4,185
  • 16
  • 20
  • The problem was with the way the function in the example code was referencing the grid id. Using $("#list").setGridWidth() also worked. – DrZ Sep 12 '11 at 21:39