Jump to content

grid resize when working with layouts


Deks

Recommended Posts

Hello,

 

am using Jqgrid and Jquery for making my webpage. I have some problems with implementing jqGrid with jquery layouts. Problem is with resizing grid on browser window resize. Height is working correctly but problem is width. It is like grid width won't refresh sometime. Also if i close left pane grid doesn't recognize new width and it stay on old.

 

To be short, i need grid width is 100% of window width.

 

For my testing am using source code from http://www.trirand.com/blog/jqgrid/jqgrid.html# .

 

I tried with

 

setTimeout(function(){
$('#' + gridId).jqGrid('setGridWidth',gridWidth);
}, 500);

 

but same things happens.

 

My code for resizing grid:

$resize = <<<RESIZE

if (document.body && document.body.offsetWidth) {
winHeight = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) {
winHeight = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winHeight = window.innerHeight;
}

wHeight = winHeight - 90;
$("#grid").jqGrid('setGridHeight',wHeight);



jQuery(window).resize(function(){
gridId = "grid";


if (document.body && document.body.offsetWidth) {
	winHeight = document.body.offsetHeight;
	}
if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) {
	winHeight = document.documentElement.offsetHeight;
	}
if (window.innerWidth && window.innerHeight) {
	winHeight = window.innerHeight;
	}


setTimeout(function(){
gridId = "grid";
gridWidth = $('#gbox_' + gridId).parent().width();
$('#' + gridId).jqGrid('setGridWidth',gridWidth);
}, 100);

wHeight = winHeight - 90;
if(wHeight < 110){
	wHeight = 110;
	$('#'+ gridId).jqGrid('setGridHeight',wHeight);
}else{
$('#'+ gridId).jqGrid('setGridHeight',wHeight);
}


})

RESIZE;
$grid->setJSCode($resize);

 

Also in index.php am using

jQuery(document).ready(function(){

$('body').layout({
	resizerClass: 'ui-state-default',
        east__onresize: function (pane, $Pane) {
            jQuery("#grid").jqGrid('setGridWidth',$Pane.innerWidth()-2);
	}
});



});

 

 

I hope someone have some experiannce and can help me.

Thanks.

 

Regards

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.