<?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: Fix Memory Leaks in emptyRows Function</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function</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/bugs/fix-memory-leaks-in-emptyrows-function/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15863</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15863</guid>
        	        	<description><![CDATA[<p>Hello Klaus,</p>
<p>Yes you are right on this.</p>
<p>Will see what I can do for this. Thanks.</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 22 Mar 2010 11:02:40 +0200</pubDate>
        </item>
        <item>
        	<title>Klaus on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15818</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15818</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>No, your suggestion did not help with my problem. The mentioned statement (</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7160' value='Select Code' data-codeid='sfcode7160' /></p>
<div class='sfcode' id='sfcode7160'>$(&#34;*&#34;,tBody).children().unbind();</div>
<p>) will only unbind all events but will not clean up the following ...</p>
<ul>
<li>any created jQuery / jQuery UI widgets</li>
<li>DOM elements and JavaScript objects (created manually or within a jQuery UI widget)</li>
</ul>
<p>For example when I attach jQuery Tooltips on cells in the table, they create some JS objects and some DOM elements (DIVs) directly on the body.</p>
<p>So the only solution to remove those objects was using the remove method which will then invoke the widget&#39;s destroy method.</p>
</p>
<p>Kind regards,<br />Klaus.</p>
]]></description>
        	        	<pubDate>Thu, 18 Mar 2010 15:51:56 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15800</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15800</guid>
        	        	<description><![CDATA[<p>Hello Klaus,</p>
<p>I understand, since this is connected with the grid.</p>
<p>Could you please try this. Lieve the emptyRows as of its original variant and just remove the</p>
<p>if(!ts.p.gridview &#124;&#124; ts.p.jqgdnd) &#8211; i.e the final code should be:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6090' value='Select Code' data-codeid='sfcode6090' /></p>
<div class='sfcode' id='sfcode6090'>
<p>&#160;&#160; &#160;&#160;&#160;&#160; emptyRows = function (parent, scroll) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var tBody = $(&#34;tbody:first&#34;, parent);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; $(&#34;*&#34;,tBody).children().unbind();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(isMSIE) $.jgrid.empty.apply(tBody[0]);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;else tBody[0].innerHTML=&#34;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (scroll &#38;&#38; ts.p.scroll) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#34;&#62;div:first&#34;, parent).css({height:&#34;auto&#34;}).children(&#34;div:first&#34;).css({height:0,display:&#34;none&#34;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;parent.scrollTop = 0;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;tBody = null;<br />&#160;&#160; &#160;&#160;&#160; &#160;},</p>
</div>
<p>If you test it this way, please let me know if this resolve the problem</p>
<p>Thanks</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 18 Mar 2010 11:02:29 +0200</pubDate>
        </item>
        <item>
        	<title>Klaus on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15693</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15693</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
</p>
<p>The memory leaks seemed to be across several browsers (IE, Firefox).</p>
<p>I hope you didn&#39;t misunderstand - not the jqGrid itself has a memory leak - but any jQuery widget attached to the grid will not be destroyed correctly but keeps somewhere in memory.</p>
<p>The only solution (I found) to destroy those attached widgets (e.g. context menues or special tooltips on cells or rows) was by calling the jQuery remove method.</p>
</p>
<p>here is the code how I create my context menu widgets:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5865' value='Select Code' data-codeid='sfcode5865' /></p>
<div class='sfcode' id='sfcode5865'>// attach context menues on all grid rows<br />var gridCompleteFunction = function() {<br />&#160; $(&#34;tr.jqgrow&#34;, &#34;#my_table&#34;).contextMenu({menu: &#34;tableMenu&#34;}, ...);<br />&#160; ...<br />}</p>
<p>// create and open context menue directly on right click cell on grid<br />var onRightClickCellFunction = function(rowid, iRow, iCol, event) {<br />&#160; var cellElem = event.target;<br />&#160; $(cellElem).contextMenu({menu: &#34;tableMenu2&#34;}, ..., &#34;doOpenDirectly&#34;);<br />}</p>
</div>
<p>The other possiblity would be to have an event when a row (or a set of rows) is removed from the table with the row objects given as parameter.</p>
</p>
<p>Or maybe you could provide a global option to decide which cleaup routine is taken in the emptyRows function (the "fast" or the "destructive" way <img class="spSmiley" style="margin:0" title="Wink" src="/blog/wp-content/forum-smileys/sf-wink.gif" alt="Wink" />)</p>
</p>
<p>Kind regards,<br />Klaus.</p>
]]></description>
        	        	<pubDate>Mon, 15 Mar 2010 10:30:57 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15667</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15667</guid>
        	        	<description><![CDATA[<p>Hello Klaus,</p>
<p>will be happy if you post a test case.</p>
<p>Also in which browser is this?</p>
<p>The main purpose of emptyRows is exactley not to use jQuery remove or empty.</p>
<p>The reason for this is that these work very slow in grid with rows &#62;= 200.</p>
<p>The last line of code in this function should do the magic</p>
</p>
<p>tBody = null;</p>
<p>This line should release all the memory</p>
</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sat, 13 Mar 2010 20:09:28 +0200</pubDate>
        </item>
        <item>
        	<title>Klaus on Fix Memory Leaks in emptyRows Function</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15645</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fix-memory-leaks-in-emptyrows-function#p15645</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I&#39;ve detected a possible memory leak (with innerHTML=""). The following solution fixed it (for me)...</p>
<p>Modified: jquery.jqGrid.js</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6455' value='Select Code' data-codeid='sfcode6455' /></p>
<div class='sfcode' id='sfcode6455'>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; emptyRows = function (parent, scroll) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var tBody = $(&#34;tbody:first&#34;, parent);</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(!ts.p.gridview &#124;&#124; ts.p.jqgdnd) $(&#34;*&#34;,tBody).children().unbind();</p>
<p>-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(isMSIE) $.jgrid.empty.apply(tBody[0]);</p>
<p>-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else tBody[0].innerHTML=&#34;&#34;;</p>
<p>+&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // fix to get embedded widgets destroyed</p>
<p>+&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(&#39;tr&#39;, tBody[0]).remove();</p>
</div>
<p>I also tried the jQuery-empty()-function, but this did not destroy embedded widgets (as tooltips bound to table rows) so I used the jQuery-remove()-function.</p>
]]></description>
        	        	<pubDate>Fri, 12 Mar 2010 15:50:46 +0200</pubDate>
        </item>
</channel>
</rss>