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
jqGrid a.grid.bDiv is null or not an object
08/08/2013
00:27
Avatar
steve_o
Member
Members
Forum Posts: 10
Member Since:
02/05/2013
sp_UserOfflineSmall Offline

I have a grid that uses a custom formatter & takes data returned to it & displays it in a jqGrid.  The function that does it is in a setInterval that runs ever so many seconds.  Using jQuery 1.9.1 & jqGrid 4.5.2.

I've noticed that the page will sometimes throw an error when the page loads, or after it has been up for several hours.  The error is:

Line: 61   Error:  'a.grid.bDiv' is null or not an object.  (IE 8).  Firefox throws a similar error on the same line of:  

TypeError:  a.grid.bDiv is null  

The module it is in is:  jquery.jqGrid.min.js

Line 61 has in it:

if(a.p.treeGrid===true)try{F.jqGrid("setTreeNode",G+1,l+G+1)}catch(S){}if(!a.p.treeGrid&&!a.p.scroll)a.grid.bDiv.scrollTop=0;a.p.reccount=l;a.p.treeANode=-1;a.p.userDataOnFooter&&F.jqGrid("footerData","set",a.p.userData,true);if(j){a.p.records=w;a.p.lastpage=Math.ceil(w/C)}g||a.updatepager(false,true);if(j)for(;l<w;){x=c[l];D=k(x,l+H);D=a.p.idPrefix+D;if(i.repeatitems){E||(E=U(s+u+m));var P=b.jgrid.getXmlData(x,i.cell,true);b.each(E,function(b){var c=P[this];if(!c)return false;o=c.textContent||c.text;

In the function where the grid is getting built, I do the following first to unload the grid.  

var ckGrid = $("#myGrid")[0];

if (ckGrid.grid) {

$("#myGrid").jqGrid("GridUnload");

}

I am retrieving 8 columns & displaying 3, one of which uses the Custom Formatter.  The Custom Formatter uses data in the hidden columns to format the data in this column.  colNames & colModel each have 8 fields defined.    The XMLReader in the jqGrid is:

xmlReader: {

root: "Rowsets",

row: "Row",

repeatitems: false,

id: "MessagingID"

},

MessagingID is a unique number.  

The custom formatter assigns 1 of three things in it - (1) a dropdown box, (2) a submit button or (3) some text.  I use rowattr to format the cells (font size, color, etc).  The Caption & the Toolbar on the grid are hidden.  

The error doesn't occur all the time though.  It's occurred once when the page loaded.  Other times, it has occurred after the page has been up for several hours.  It so happens that there are no rows on the grid (which is a legitimate condition).  

I don't know why it is getting into that code above, or what the issue could be with it.  It may be a bug, but I have not been able to find out anything about someone else encountering it.  I have not been able to (knowingly) do anything to reproduce it, I have only been able to observe it once it has happened.  The issue has been most prominent on IE8, but it has also occurred a couple times in Firefox.

I'll be glad to post whatever pertinent data might be required about the jqGrid definition I have if it would be useful.  just let me know what portion(s) of it would be relevant.  

08/08/2013
14:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This is little difficult to reproduce.

If you unload the grid, the use maybe a setTimeout to create it and obtain data. It is quite possible that under some conditions

you try toload a data on non existing grid.

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.

08/08/2013
18:57
Avatar
steve_o
Member
Members
Forum Posts: 10
Member Since:
02/05/2013
sp_UserOfflineSmall Offline

This is little difficult to reproduce.

If you unload the grid, the use maybe a setTimeout to create it and obtain data. It is quite possible that under some conditions

you try toload a data on non existing grid.

Regards


Thank you, Tony.  I was able to get the error to occur (in Firefox) 1 time, and it was on the first time I opened the page.  I tried 20+ times after that without ever getting it to happen again.  I saw that it had happened again overnight, but in a different line.  It was in 76-78 on a.grid.hDiv being null or not an object.  

The page itself has to be up 24 hours a day & re-creates the grid after so many seconds.  The general process goes as follows:

  1. On $(document).ready(), the page load time is obtained & we calculate how long to run the page until we force a page load ( window.location.reload() ).  This (how long before the end of this shift) is done using setTimeout("forcepageReload()", whenToReload);  
  2. I then call the function to build the grid for the first time (runs 1 time on $(document).ready() ).
  3. Then I call the function restartInt(); that starts the Interval (this & the above items are all in the $(document).ready() section of the page).  

The start interval function restartInt() does the following:

  1. Clears the interval variable.
  2. Does some housekeeping to find out when the interval before this one was 
  3. sets the interval variable which calls the function to build the grid & passes in the parameters from the housekeeping above and sets the interval to be on so many seconds.  

The function getMsg4Grid that builds the grid is where all of the processing takes place.  

  1. It checks to see if the grid exists & if so, unloads it.  
  2. It then builds the grid.  A Custom formatter is used to assign data in one column.  One of three items are displayed in this column (dependent on data):  a DropDown box, a Submit button or text.  rowattr is used to change font size and/or color as required.
  3. In the loadComplete, the caption & toolbar are hidden & the grid row height is changed. 
  4. In beforeSelectRow I monitor for the button click (which updates a table).  In here I also check for (a) the dropdown box to be opened, and (b) a selection from the dropdown is made.  
  5. When the dropdown box is opened (a in step above), I clear the interval (I do not want the grid to reload while the dropdown box is open before a selection is made).  I set variables to when the interval was stopped.  
  6. When a selection in the dropdown is made (b in beforeSelectRow step above) I update a table.  When the table is updated, I then call the function to rebuild the grid 1 time (using the variables from when the interval was stopped as input).  After that, I have a setTimeout statement to restart the interval.

The code in step 6 above is:

getMsg4Grid(some input parameters from interval stop);

setTimeout(restartInt, 5);

Since the page has to be up all the time & gets re-built every so many seconds, I chose to use setInterval over setTimeout to avoid possible stack issues.  I don't know if that is correct, as each of them has their own set of advantages & disadvantages.  

The only time the interval is cleared is (1) when the dropdown box has been opened & before a selection is made, and (2) as part of the restartInt() function.  It also gets cleared (although not directly) as part of the forcepageReload() function when the page reloads itself.  

When the function to build the grid gets called, I supply ( among other things) a date & time parameter.  So, calls would be like:

  • 1stTime -  2013-08-08 10:18:20.313
  • 2ndTime - 2013-08-08 10:18:50.313
  • 3rdTime - 2013-08-08 10:19:20.444
  • 4thTime - 2013-08-08 10:19:50.400
  • 5thTime - 2013-08-08 10:20:20.899

The URL that I'm using in the jqGrid build has that date & time as one of the parameters.  It is calling a stored procedure that is using that time to retrieve items only since the time parameter that was passed in.    I know that the setInterval is changing these times as they should.  In looking at the GET requests in firebug, I see the time parameter changing as it should.  

Questions I had - 

  1. Is the GridUnload method necessary in this case? What I don't want to happen is for the grid to keep being rebuilt using the URL from a couple hours ago when I think it's using the data I'm passing into it.  
  2. If using GridUnload is necessary, can the jqGrid be instantiated immediately after the GridUnload, but empty, and then followed by the call to reload/refresh the grid (which uses the new, updated URL with the new date time parameters in it)?  
  3. Am I mistaken about the setTimeout vs setInterval tradeoffs (too much recursion vs queued calls)?  
  4. Is there a better way to do what I need to do on this page using jqGrid?  

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
42 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