<?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: Slow performance using addRowData</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/slow-performance-using-addrowdata</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/slow-performance-using-addrowdata/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>kalinwilson on Slow performance using addRowData</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/slow-performance-using-addrowdata#p21861</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/slow-performance-using-addrowdata#p21861</guid>
        	        	<description><![CDATA[<p>As I mentioned in my previous post, I&#39;m using two grids with local data as a multi-select mechanism. The candidate grid is populated using addRowData in an ajax callback that receives an array of JSON objects from the server. I&#39;ve noticed that if grouping is defined and activated the grid is populated and rendered quickly (1-2s for 500 rows). If grouping is false or undefined, the rendering is very slow. The visible rows may render fairly quickly but the grid is unresponsive until all rows are defined. Grouping appeared to be broken as when the data was sorted/grouped, I would lose the last row of data. But this may be because I had rowNum:-1 to display all rows. I&#39;ll use a large number and see if the sort/grouping works correctly.</p>
<p>What is the most efficient way to load a potentially large local data set? I tried addJSONData but it didn&#39;t work with either a straight array of objects or with the &#39;pages&#39;, totalPages&#39;, etc defined for the reader.</p>
<p>here is my grid definition and the code for the loader:</p>
<blockquote>
<p>var candidateGridOpts = {</p>
<p>&#160; datatype: &#39;local&#39;,</p>
<p>&#160; colNames: [&#39;Id&#39;, &#39;Name&#39;, &#39;Type&#39;, &#39;ClassId&#39;],</p>
<p>&#160; colModel: [{name:&#39;id&#39;, index:&#39;id&#39;, width:50,hidden:true,sortable:false, formatter:&#39;integer&#39;,editable:false,sorttype:&#39;int&#39;},</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;name&#39;, index:&#39;name&#39;,width:300,sortable:false,editable:false}</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;type&#39;,index:&#39;type&#39;,width:100,sortable:false,editable:false,summaryType:&#39;count&#39;,summaryTpl:&#39;{0}&#39;},</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;classId&#39;,index:&#39;classId&#39;,width:250,hidden:true, sortable:false,editable:false}],</p>
<p>&#160; height:&#39;300&#39;,</p>
<p>&#160; width:&#39;50%&#39;,</p>
<p>&#160; autowidth:false,</p>
<p>&#160; rowNum:-1,</p>
<p>&#160; rownumbers:true,</p>
<p>&#160; rownumberWidth:40,</p>
<p>&#160; sortname:&#39;name&#39;,</p>
<p>&#160; sortorder:&#39;asc&#39;,</p>
<p>&#160; hidegrid:false,</p>
<p>&#160; gridview:false,</p>
<p>&#160; footerrow:true,</p>
<p>&#160; caption: &#39;Candidates&#38;nbsp;&#38;nbsp;&#60;button id="clearCandidatesButton"&#62;Clear&#60;/button&#62;&#39;,</p>
<p>&#160; grouping:true,</p>
<p>&#160; groupingView: {groupField:[&#39;type&#39;], groupDataSorted:false, groupColumnShow:[true], groupText:[&#39;{0} ({1})&#39;]}</p>
<p>}</p>
<p>// the other grid is defined similarly</p>
</p>
<p>// definded outside ready function. this is a callback for ajaxForm</p>
<p>function displayCandidates(candidates, status, request, form){</p>
<p>&#160; jQuery("#candidateList").jqGrid(&#39;clearGridData&#39;);</p>
<p>&#160; if(candidates.length &#60; 1){</p>
<p>&#160;&#160;&#160; alert("No Candidates were found for your query");</p>
<p>&#160; } else {</p>
<p>&#160;&#160;&#160; for(var i=0; i &#60; candidates.length; i++){</p>
<p>&#160;&#160;&#160;&#160;&#160; jQuery("#candidateList").jqGrid(&#39;addRowData&#39;, candidates[i].classId, candidates[i]);</p>
<p>&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; updateFooters();</p>
<p>&#160; }</p>
<p>}</p>
</blockquote>
<p>Originally I had a jsonReader defined to populate cells by name. I can&#39;t remember when I removed that from the grid options. Perhaps defining the jsonReader would help. Still it&#39;s odd that rendering is faster if grouping is on.</p></p>
]]></description>
        	        	<pubDate>Fri, 28 Jan 2011 06:02:38 +0200</pubDate>
        </item>
</channel>
</rss>