Forum
17:29
12/12/2012
Hello everyone,
I need to resize jqGrid when user resizes a browser. So, I used the following code:
$(window).bind('resize', function () {
$("#grid").jqGrid('setGridWidth', 1000);
});
I notified that in IE8 that construction goes to infinite cycle. I've investigated it and found that setGridWidth calls $.jgrid.cellWidth() inside.
$.jgrid.cellWidth() contains following code:
var $testDiv = $("<div class='ui-jqgrid' style='left:10000px'><table class='ui-jqgrid-btable' style='width:5px;'><tr class='jqgrow'><td style='width:5px;'></td></tr></table></div>"),
testCell = $testDiv.appendTo("body").find("td").width();
$testDiv.remove();
return testCell !== 5;
Exactly that code forces window to rise resize event in IE8.
I would really appreciate to any suggestions how to fix this problem or how to resize jqGrid when user resizes the browser.
Thank in advance.
18:36
Moderators
30/10/2007
Hello,
Use setTimeout when you call the setGridwidth.
$(window).bind('resize', function () {
setTimeout(function(){ $("#grid").jqGrid('setGridWidth', 1000);},100);
});
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
09:16
12/12/2012
Hello tony,
Thank you for your suggestion but it does not fix that problem. Function setGridWidth forces window to rise 'resize' event (IE8) in any case: use timeout or not.
The main problem is the implementation of the $.jgrid.cellWidth() function that is invoked inside the setGridWidth.
Here is the simple code to reproduce it:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="Script/jquery-1.8.0.js"></script>
<script src="Script/jquery.jqGrid.src.js"></script>
<script type="text/javascript" language="JavaScript">
var count = 1;
$(function(){
initGrid();
$(window).bind('resize', function() {
setTimeout(function() {
$('#grid').setGridWidth(1000);
$('body').append(count++);
}, 100);
});
});
function initGrid() {
var options = {};
$('#grid').jqGrid(options);
};
</script>
</head>
<body>
<div>
<table id="grid"></table>
</div>
</body>
</html>
In my project I've just overrided the $.jgrid.cellWidth() function to return true. But I suppose it's not good solution.
Regards.
10:31
Moderators
30/10/2007
Hello,
I have fixed the problem in GitHub.
Could you please let me know if this ok for you?
Thanks.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
81 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66