Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
$.jgrid.cellWidth() function forces IE8 to throw window.resize event
12/12/2012
17:29
Avatar
putnik
Member
Members
Forum Posts: 3
Member Since:
12/12/2012
sp_UserOfflineSmall Offline

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.

12/12/2012
18:36
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

13/12/2012
09:16
Avatar
putnik
Member
Members
Forum Posts: 3
Member Since:
12/12/2012
sp_UserOfflineSmall Offline

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.

13/12/2012
10:31
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

03/01/2013
09:49
Avatar
putnik
Member
Members
Forum Posts: 3
Member Since:
12/12/2012
sp_UserOfflineSmall Offline

Hello,

Sorry for the delay.

Thank you for the solution very much.

It works perfectly.

For my soultion I've just overrided the cellWidth() function to return true. It also works without any changes in the jqGrid code.

Kind Regards,

Andrew Zhuk

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
18 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information