<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: jqGrid a.grid.bDiv is null or not an object</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>steve_o on jqGrid a.grid.bDiv is null or not an object</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29303</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29303</guid>
        	        	<description><![CDATA[<blockquote>
<p>This is little difficult to reproduce.</p>
<p>If you unload the grid, the use maybe a setTimeout to create it and obtain data. It is quite possible that under some conditions</p>
<p>you try toload a data on non existing grid.</p>
</p>
<p>Regards</p>
</blockquote>
<hr />
<p>Thank you, Tony. &#160;I was able to get the error to occur (in Firefox) 1 time, and it was on the first time I opened the page. &#160;I tried 20+ times after that without ever getting it to happen again. &#160;I saw that it had happened again overnight, but in a different line. &#160;It was in 76-78 on <strong>a.grid.hDiv</strong> being null or not an object. &#160;</p>
</p>
<p>The page itself has to be up 24 hours a day &#38; re-creates the grid after so many seconds. &#160;The general process goes as follows:</p>
<ol>
<li>On $(document).ready(), the page load time is obtained &#38; we calculate how long to run the page until we force a page load ( window.location.reload() ). &#160;This (how long before the end of this shift)&#160;is done using <strong>setTimeout("forcepageReload()", whenToReload);</strong> &#160;</li>
<li>I then call the function to build the grid for the first time (runs 1 time on $(document).ready() ).</li>
<li>Then I call the function <strong>restartInt();</strong>&#160;that starts the Interval (this &#38; the above items are all in the $(document).ready() section of the page). &#160;</li>
</ol>
<p>The start interval <strong>function restartInt()</strong> does the following:</p>
<ol>
<li>Clears the interval variable.</li>
<li>Does some housekeeping to find out when the interval before this one was&#160;</li>
<li>sets the interval variable which calls the function to build the grid &#38; passes in the parameters from the housekeeping above and sets the interval to be on so many seconds. &#160;</li>
</ol>
<p>The <strong>function getMsg4Grid</strong>&#160;that builds the grid is where all of the processing takes place. &#160;</p>
<ol>
<li>It checks to see if the grid exists &#38; if so, unloads it. &#160;</li>
<li>It then builds the grid. &#160;A Custom formatter is used to assign data in one column. &#160;One of three items are displayed in this column (dependent on data): &#160;a DropDown box, a Submit button or text. &#160;<strong>rowattr</strong> is used to change font size and/or color as required.</li>
<li>In the <strong>loadComplete</strong>, the caption &#38; toolbar are hidden &#38; the grid row height is changed.&#160;</li>
<li>In <strong>beforeSelectRow</strong> I monitor for the button click (which updates a table). &#160;In here I also check for (a) the dropdown box to be opened, and (b) a selection from the dropdown is made. &#160;</li>
<li>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). &#160;I set variables to when the interval was stopped. &#160;</li>
<li>When a selection in the dropdown is made (b in <strong>beforeSelectRow</strong> step above) I update a table. &#160;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). &#160;After that, I have a <strong>setTimeout</strong> statement to restart the interval.</li>
</ol>
<p>The code in step 6 above is:</p>
<p style="padding-left: 60px;">getMsg4Grid(some input parameters from interval stop);</p>
<p style="padding-left: 60px;">setTimeout(restartInt, 5);</p>
</p>
<p>Since the page has to be up all the time &#38; gets re-built every so many seconds, I chose to use setInterval over setTimeout to avoid possible stack issues. &#160;I don&#39;t know if that is correct, as each of them has their own set of advantages &#38; disadvantages. &#160;</p>
<p>The only time the interval is cleared is (1) when the dropdown box has been opened &#38; before a selection is made, and (2) as part of the <strong>restartInt()</strong> function. &#160;It also gets cleared (although not directly) as part of the <strong>forcepageReload()</strong> function when the page reloads itself. &#160;</p>
</p>
<p>When the function to build the grid gets called, I supply ( among other things) a date &#38; time parameter. &#160;So, calls would be like:</p>
<ul>
<li>1stTime - &#160;2013-08-08 10:18:20.313</li>
<li>2ndTime - 2013-08-08 10:18:50.313</li>
<li>3rdTime - 2013-08-08 10:19:20.444</li>
<li>4thTime - 2013-08-08 10:19:50.400</li>
<li>5thTime - 2013-08-08 10:20:20.899</li>
</ul>
<p>The URL that I&#39;m using in the jqGrid build has that date &#38; time as one of the parameters. &#160;It is calling a stored procedure that is using that time to retrieve items only since the time parameter that was passed in. &#160; &#160;I know that the setInterval is changing these times as they should. &#160;In looking at the GET requests in firebug, I see the time parameter changing as it should. &#160;</p>
</p>
<p>Questions I had -&#160;</p>
<ol>
<li>Is the <strong>GridUnload </strong>method necessary in this case? What I <span style="text-decoration: underline;">don&#39;t</span> want to happen is for the grid to keep being rebuilt using the URL from a couple hours ago when I think it&#39;s using the data I&#39;m passing into it. &#160;</li>
<li>If using <strong>GridUnload</strong> is necessary, can the jqGrid be instantiated immediately after the <strong>GridUnload</strong>, 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)? &#160;</li>
<li>Am I mistaken about the setTimeout vs setInterval tradeoffs (too much recursion vs queued calls)? &#160;</li>
<li>Is there a better way to do what I need to do on this page using jqGrid? &#160;</li>
</ol>
]]></description>
        	        	<pubDate>Thu, 08 Aug 2013 18:57:07 +0300</pubDate>
        </item>
        <item>
        	<title>tony on jqGrid a.grid.bDiv is null or not an object</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29297</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29297</guid>
        	        	<description><![CDATA[<p>Hello,</p>
</p>
<p>This is little difficult to reproduce.</p>
<p>If you unload the grid, the use maybe a setTimeout to create it and obtain data. It is quite possible that under some conditions</p>
<p>you try toload a data on non existing grid.</p>
</p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Thu, 08 Aug 2013 14:12:45 +0300</pubDate>
        </item>
        <item>
        	<title>steve_o on jqGrid a.grid.bDiv is null or not an object</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29293</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-a-grid-bdiv-is-null-or-not-an-object#p29293</guid>
        	        	<description><![CDATA[<p>I have a grid that uses a custom formatter &#38; takes data returned to it &#38; displays it in a jqGrid. &#160;The function that does it is in a setInterval that runs ever so many seconds. &#160;Using jQuery 1.9.1 &#38; jqGrid 4.5.2.</p>
</p>
<p>I&#39;ve noticed that the page will sometimes throw an error when the page loads, or after it has been up for several hours. &#160;The error is:</p>
<p><strong>Line: 61 &#160; Error: &#160;&#39;a.grid.bDiv&#39; is null or not an object</strong>. &#160;(IE 8). &#160;Firefox throws a similar error on the same line of: &#160;</p>
<p><strong>TypeError: &#160;a.grid.bDiv is null &#160;</strong></p>
</p>
<p>The module it is in is: &#160;jquery.jqGrid.min.js</p>
</p>
<p>Line 61 has in it:</p>
</p>
<p>if(a.p.treeGrid===true)try{F.jqGrid("setTreeNode",G+1,l+G+1)}catch(S){}if(!a.p.treeGrid&#38;&#38;!a.p.scroll)<strong>a.grid.bDiv</strong>.scrollTop=0;a.p.reccount=l;a.p.treeANode=-1;a.p.userDataOnFooter&#38;&#38;F.jqGrid("footerData","set",a.p.userData,true);if(j){a.p.records=w;a.p.lastpage=Math.ceil(w/C)}g&#124;&#124;a.updatepager(false,true);if(j)for(;l&#60;w;){x=c[l];D=k(x,l+H);D=a.p.idPrefix+D;if(i.repeatitems){E&#124;&#124;(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&#124;&#124;c.text;</p>
</p>
<p>In the function where the grid is getting built, I do the following first to unload the grid. &#160;</p>
</p>
<p>var ckGrid = $("#myGrid")[0];</p>
<p>if (ckGrid.grid) {</p>
<p>$("#myGrid").jqGrid("GridUnload");</p>
<p>}</p>
</p>
<p>I am retrieving 8 columns &#38; displaying 3, one of which uses the Custom Formatter. &#160;The Custom Formatter uses data in the hidden columns to format the data in this column. &#160;colNames &#38; colModel each have 8 fields defined. &#160; &#160;The XMLReader in the jqGrid is:</p>
</p>
<p>xmlReader:  {</p>
<p>root: "Rowsets",</p>
<p>row: "Row",</p>
<p>repeatitems: false,</p>
<p>id: "MessagingID"</p>
<p>},</p>
<p>MessagingID is a unique number. &#160;</p>
</p>
<p>The custom formatter assigns 1 of three things in it - (1) a dropdown box, (2) a submit button or (3) some text. &#160;I use rowattr to format the cells (font size, color, etc). &#160;The Caption &#38; the Toolbar on the grid are hidden. &#160;</p>
</p>
<p>The error doesn&#39;t occur all the time though. &#160;It&#39;s occurred once when the page loaded. &#160;Other times, it has occurred after the page has been up for several hours. &#160;It so happens that there are no rows on the grid (which is a legitimate condition). &#160;</p>
</p>
<p>I don&#39;t know why it is getting into that code above, or what the issue could be with it. &#160;It may be a bug, but I have not been able to find out anything about someone else encountering it. &#160;I have not been able to (knowingly) do anything to reproduce it, I have only been able to observe it once it has happened. &#160;The issue has been most prominent on IE8, but it has also occurred a couple times in Firefox.</p>
</p>
<p>I&#39;ll be glad to post whatever pertinent data might be required about the jqGrid definition I have if it would be useful. &#160;just let me know what portion(s) of it would be relevant. &#160;</p>
]]></description>
        	        	<pubDate>Thu, 08 Aug 2013 00:27:46 +0300</pubDate>
        </item>
</channel>
</rss>