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
https://forums.phpfreaks.com/topic/249307-grid-resize-when-working-with-layouts/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.