<?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: addXmlData local with pager rowid bug</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug</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/addxmldata-local-with-pager-rowid-bug/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26396</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26396</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I have made the fix <img class="spSmiley" style="margin:0" title="Wink" src="/blog/wp-content/forum-smileys/sf-wink.gif" alt="Wink" /></p>
</p>
<p><a href="https://github.com/tonytomov/jqGrid/commit/c9304338b37bb57bea608356e0ec0a522b1366f2" rel="nofollow" target="_blank">https://github.com/tonytomov/jqGrid/commit/c9304338b37bb57bea608356e0ec0a522b1366f2</a></p>
</p>
<p>Thanks</p>
<p>Regards</p></p>
]]></description>
        	        	<pubDate>Wed, 18 Apr 2012 12:09:46 +0300</pubDate>
        </item>
        <item>
        	<title>tedt3 on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26395</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26395</guid>
        	        	<description><![CDATA[<p>Thanks for the suggestion to assign the row id using the id attribute for the row tag.&#160; While that works correctly&#160;there is still a bug as I have stated in the previous posts.</p>
</p>
<p>Here is the getId function used in addXmlData.</p>
<p><strong>getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) &#124;&#124; k;};</strong></p>
<p>&#160;it works fine when it has the id attribute in the row tag.&#160; But if the attribute is not used (and it&#39;s not used in any of the examples from the link you provided) it just returns k which was passed in.</p>
</p>
<p>Then in the addXmlData function there are 2 loops.</p>
</p>
<p>The first loop whilch runs until it breaks out when the rowNum parameter to the jqGrid function is reached calls getId like this</p>
<p>&#160;&#160;<strong>&#160;&#160;rid = getId(xmlr,br+j);&#160; The br in my case&#160; is 1 and not random because scroll grid parameter is set to false.&#160;so 1 is added to each rowid.</strong></p>
<p><strong>var br=ts.p.scroll?$.jgrid.randId():1,altr;</strong></p>
<p><strong>&#160;</strong></p>
<p>Then since I am loading the entire grid at once the second loop processes the rest of the rows that aren&#39;t currently displayed.&#160; But it calls getId like this</p>
<p><strong>rid = getId(xmlr,ir);&#160; </strong></p>
<p><strong>It no longer is adding br</strong> <strong>so rid is set to the current row.</strong></p>
<p><strong>&#160;</strong></p>
<p>That is a problem because the rows read in the first loop are using a 1 based counter because of the +br&#160;and the rows read in the second loop are using a 0 based counter.&#160;</p>
</p>
<p><strong><br /></strong></p>
]]></description>
        	        	<pubDate>Wed, 18 Apr 2012 06:01:16 +0300</pubDate>
        </item>
        <item>
        	<title>tony on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26393</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26393</guid>
        	        	<description><![CDATA[<p>Or set the id in the response:</p>
</p>
<p>&#60;result&#62;</p>
<p>&#60;rows&#62;</p>
<p><strong>&#60;row id=&#39;1&#39;&#62;</strong></p>
<p>&#60;cell&#62;row1&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p><strong>&#60;row id=&#39;2&#39;&#62;</strong></p>
<p>&#60;cell&#62;row2&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p><strong>&#60;row id=&#39;3&#39;&#62;</strong></p>
<p>&#60;cell&#62;row3&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
]]></description>
        	        	<pubDate>Wed, 18 Apr 2012 00:22:59 +0300</pubDate>
        </item>
        <item>
        	<title>tony on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26392</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26392</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>As I say the xml is not suitable for jqGrid.</p>
<p>You should configure the id row - i.e. thel the grid which is the id from thew response.</p>
<p>Please read here before to make any conclusions:</p>
<p><a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#xml_data" rel="nofollow" target="_blank"><a href="http://www.trirand.com/jqgridw" rel="nofollow">http://www.trirand.com/jqgridw</a>.....a#xml_data</a></p>
</p>
<p>The easy way is to use this definition:</p>
<p>var colModelArray = [{name:&#39;col1&#39;, index:&#39;col1&#39;, sortype:&#39;string&#39;, editable:false, <strong>key:true</strong>}];</p>
</p>
<p>Regards</p></p>
]]></description>
        	        	<pubDate>Wed, 18 Apr 2012 00:18:34 +0300</pubDate>
        </item>
        <item>
        	<title>tedt3 on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26386</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26386</guid>
        	        	<description><![CDATA[<p>I&#39;ve already tried the 0 based vs 1 based loop.&#160; Doing what you suggest results in this.</p>
<table border="0">
<tbody>
<tr>
<th>Row</th>
<th>Data</th>
</tr>
<tr>
<td>0</td>
<td>undefined</td>
</tr>
<tr>
<td>1</td>
<td>row1</td>
</tr>
<tr>
<td>2</td>
<td>row2</td>
</tr>
<tr>
<td>3</td>
<td>row4</td>
</tr>
<tr>
<td>4</td>
<td>row5</td>
</tr>
</tbody>
</table>
<p>rowID 0 is invalid so no data row returned</p>
<p>rowIDs 1 and 2 return the correct rows</p>
<p>rowID 3 which is equal to the rowNum grid paramter should return a row with the value "row3" instead it returs the next row.</p>
<p>All rows after this return the row after it instead of the correct row.</p>
]]></description>
        	        	<pubDate>Tue, 17 Apr 2012 21:34:38 +0300</pubDate>
        </item>
        <item>
        	<title>tony on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26384</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26384</guid>
        	        	<description><![CDATA[<p>Try with this loop instead:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6457' value='Select Code' data-codeid='sfcode6457' /></p>
<div class='sfcode' id='sfcode6457'>
<p>...</p>
<p>for (var i = 0; i &#60; TotalRows; i++)</p>
<p>{</p>
<p>var rowObj = $(&#39;#grid&#39;).getLocalRow(i);</p>
<p>debugStr = debugStr + "&#60;tr&#62;&#60;td&#62;" + i + "&#60;/td&#62;&#60;td&#62;" + rowObj.col1 + "&#60;/td&#62;&#60;/tr&#62;";</p>
<p>}</p>
<p>..</p>
</div>
<p>The response instread is not correct - there are miised tags for records page and etc.</p></p>
]]></description>
        	        	<pubDate>Tue, 17 Apr 2012 21:06:38 +0300</pubDate>
        </item>
        <item>
        	<title>tedt3 on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26382</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26382</guid>
        	        	<description><![CDATA[<p><strong>No I&#39;m pretty sure it&#39;s not my code that is causing this. I&#39;ve created a small example that does the same thing.</strong></p>
<p><strong>Here is a sample xml file</strong></p>
<p>&#60;!&#8211;</p>
<p>&#60;?xml version="1.0&#8243; encoding="utf-8&#8243;?&#62;</p>
<p>&#60;result&#62;</p>
<p>&#60;rows&#62;</p>
<p>&#60;row&#62;</p>
<p>&#60;cell&#62;row1&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;row&#62;</p>
<p>&#60;cell&#62;row2&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;row&#62;</p>
<p>&#60;cell&#62;row3&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;row&#62;</p>
<p>&#60;cell&#62;row4&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;row&#62;</p>
<p>&#60;cell&#62;row5&#60;/cell&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;/row&#62;</p>
<p>&#60;/rows&#62;</p>
<p>&#60;/result&#62;</p>
<p>&#8211;&#62;</p>
<p><strong>And here is a sample html page. Notice I have rowNum set to 2 in my grid so it only shows 2 rows at a time.</strong></p>
<p>&#60;!&#8211;</p>
<p>&#60;html&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" href="../jqgrid/css/ui.jqgrid.css" /&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" href="../jquery_ui/css/ui-lightness/jquery-ui-1.8.17.custom.css" /&#62;</p>
<p>&#60;script type="text/javascript" src="../jquery_ui/js/jquery-1.7.1.min.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript" src="../jquery_ui/js/jquery-ui-1.8.17.custom.min.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript" src="../jqgrid/js/i18n/grid.locale-en.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript"src="../jqgrid/js/jquery.jqGrid.min.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>function fillGrid()</p>
<p>{</p>
<p>var colModelArray = [{name:&#39;col1&#39;, index:&#39;col1&#39;, sortype:&#39;string&#39;, editable:false}];</p>
<p>var colNamesArray = [&#39;Column1&#39;];</p>
<p>jQuery("#grid").jqGrid({</p>
<p>datatype: "xml",</p>
<p>url: "data.xml",</p>
<p>colNames: colNamesArray,</p>
<p>colModel: colModelArray,</p>
<p>height: &#39;auto&#39;,</p>
<p>autowidth: true,</p>
<p>rowNum: 2,</p>
<p>pager: &#39;#grid_pager&#39;,</p>
<p>rowList:[2, 5],</p>
<p>viewrecords: true,</p>
<p>loadonce: true,</p>
<p>processing: true</p>
<p>});</p>
<p>jQuery("#grid").navGrid(&#39;#grid_pager&#39;,{edit:false,add:false,del:false,search:true,refresh:false});</p>
<p>}</p>
<p>function checkRows()</p>
<p>{</p>
<p>var TotalRows = $("#grid").getGridParam("records");</p>
<p>var debugStr = "&#60;table&#62;&#60;tr&#62;&#60;th&#62;Row&#60;/th&#62;&#60;th&#62;Data&#60;/th&#62;&#60;/tr&#62;";</p>
<p>for (var i = 1; i &#60;= TotalRows; i++)</p>
<p>{</p>
<p>var rowObj = $(&#39;#grid&#39;).getLocalRow(i);</p>
<p>debugStr = debugStr + "&#60;tr&#62;&#60;td&#62;" + i + "&#60;/td&#62;&#60;td&#62;" + rowObj.col1 + "&#60;/td&#62;&#60;/tr&#62;";</p>
<p>}</p>
<p>debugStr = debugStr + "&#60;/table&#62;";</p>
<p>$(&#39;#grid_debug&#39;).html(debugStr);</p>
<p>}</p>
<p>$(document).ready(function(){</p>
<p>fillGrid();</p>
<p>});</p>
<p>&#60;/script&#62;</p>
<p>&#60;body&#62;</p>
<p>&#60;div style="width: 600px;"&#62;</p>
<p>&#60;div style="float: left; width: 600px;"&#62;</p>
<p>&#60;table id="grid"&#62;&#60;/table&#62;</p>
<p>&#60;div id="grid_pager"&#62;&#60;/div&#62;</p>
<p>&#38;nbsp;</p>
<p>&#60;/div&#62;</p>
<p>&#60;div style="float: left; width: 600px;"&#62;</p>
<p>&#60;div id="grid_debug"&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;div style="float: left; width: 600px;"&#62;</p>
<p>&#60;input type="button" onClick="checkRows();" value="Check Grid Rows"&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
<p>&#8211;&#62;</p>
<p><strong>After the page loads if you hit the Check Grid Rows Button you will see the following:</strong></p>
<p>Row Data</p>
<p>1 row1</p>
<p>2 row3</p>
<p>3 row4</p>
<p>4 row5</p>
<p>5 undefined</p>
<p><strong>Notice how Row 2 doesn&#39;t show row2 instead it shows row3. Now if I keep all the code above identical except change rowNum parameter of the grid to 3 I get this:</strong></p>
<p>Row Data</p>
<p>1 row1</p>
<p>2 row2</p>
<p>3 row4</p>
<p>4 row5</p>
<p>5 undefined</p>
]]></description>
        	        	<pubDate>Tue, 17 Apr 2012 17:01:39 +0300</pubDate>
        </item>
        <item>
        	<title>tony on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26381</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26381</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Humm, actally this is partial true. This means that something is wrong with your response or configuration.</p>
<p>That is the: &#160;rid = getId(xmlr, br + ir); - i.e br+ir is called only in case the grid can not find the cell or you maybe forgot to set the index property in colModel or you forgot to set key:true propery for the column which should act as id.</p>
<p>Just look for getId and see the k parameter</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3907' value='Select Code' data-codeid='sfcode3907' /></p>
<div class='sfcode' id='sfcode3907'>
<p>1. getId = function( trow, k) {return $(idn,trow).text() &#124;&#124; k;};</p>
<p>or</p>
<p>2.getId = function( trow, k) {return $(xmlRd.cell,trow).eq(idn).text() &#124;&#124; k;}; 				}&#160;</p>
<p>or</p>
<p>3. getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) &#124;&#124; k;};</p>
</div>
<p>Regards</p></p>
]]></description>
        	        	<pubDate>Tue, 17 Apr 2012 14:19:22 +0300</pubDate>
        </item>
        <item>
        	<title>tedt3 on addXmlData local with pager rowid bug</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26360</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/addxmldata-local-with-pager-rowid-bug#p26360</guid>
        	        	<description><![CDATA[<p>Only the first group of rows until the grids rowNum parameter are assigned the correct rowid.&#160; Everything that follows has a rowid that is 1 higher than it should.</p>
<p>So if for example&#160;I have 50 rows and I have a rowNum of 25 to display only 25 rows on the grid at a time I can only call getLocalRow() for the first 24 rows.&#160; Once I call getLocalRow passing 25 or above I am returned the row after the row I am requesting.</p>
<p>Looking at the source for addXmlData</p>
<p>In the first loop getId is called like this: rid = getId(xmlr,br+j);</p>
<p>In the second loop that loads all data after rowNum getId is called like this: rid= getId(xmlr, ir);</p>
<p>Changing this&#160;line&#160;to rid = getId(xmlr, br + ir);&#160; appears to fix the issue</p>
]]></description>
        	        	<pubDate>Thu, 12 Apr 2012 23:06:15 +0300</pubDate>
        </item>
</channel>
</rss>