DrZ
DrZ

Reputation: 181

Resizing a jqGrid when window resizes using UI.Layout

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.

Upvotes: 0

Views: 2324

Answers (1)

RoccoC5
RoccoC5

Reputation: 4213

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.

Upvotes: 1

Related Questions