0

I have a dashboard with several jqgrids. My dashboard windows can individually expand to fill up the page while all other windows disapear. There is also a toggle to shrink back

If i have a jqgrid, in that window, when it expands I would like the grid width to expand and shrink a as well.

Is there some way to bind the grid to its parent div so it can expand and shrink?

Sample so far which does not work.

$('.portlet-content').bind('resize', function() {
        jQuery("#gridConfirm").setGridWidth($('.portlet-content').width()-5, true);
    }).trigger('resize'); 
Darren Cato
  • 1,382
  • 16
  • 22
  • Do you tried the way from [here](http://stackoverflow.com/questions/875225/resize-jqgrid-when-browser-is-resized)? – Oleg Oct 07 '11 at 20:50
  • I actually use that code elsewhere, however it does not work for divs. At least it has not worked for me. – Darren Cato Oct 07 '11 at 20:53
  • You should just get `$('#parentDiv').width()` inside of the `resize` event handler. – Oleg Oct 07 '11 at 21:11
  • Right that i can do, but i dont know how to build the resize event handler. I've added what i have. – Darren Cato Oct 07 '11 at 21:34

1 Answers1

1

You should bind jQuery.resize to the window object. Try this one

$(window).resize(function() {
    $("#gridConfirm").jqGrid('setGridWidth', $('.portlet-content').width()-5, true);
}).trigger('resize');
Oleg
  • 220,925
  • 34
  • 403
  • 798