I have a (weird ?) problem with JQGrid. I am populating the grid with local XML. I have set a JQGrid with rowNum:10 and rowList:[10,20,30,40,50].
I have 12 records.
The data (initially 10) is loaded perfectly in the grid and the table IDs are [“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”]. When I change the rowList to 20, the table IDs are [“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “10”, “11”]. The number 10 is shown twice.
Have anybody seen this error before ?
Thanks in advance.
JQuery version: 1.4.2
jqGrid version : 3.8.1
Code Snippets
The xml we have here is :
<?xml version=’1.0′ encoding=’utf-8′?><root><rows><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row><row><cell>prasanth</cell><cell>kumar</cell></row></rows></root>
The JQGrid is defined by the following code:
jQuery("#tableGrid").jqGrid(
{
datatype: "xmlstring",
datastr : mystr,
height: 'auto',
rowNum: 10,
rowList: [10,20,30,40,50],
colNames:['First Name', 'Last Name'],
colModel:[ {name:'firstname', width:7, sorttype:"string"},
{name:'lastname', width:7, sorttype:"string"}
],
pager: "#pager",
viewrecords: true,
sortname: 'firstname',
autowidth:true,
grouping:false
});
When I check in firebug after changing the rowlist to 20, the rows are created as below:
<tr id="9" class="ui-widget-content jqgrow ui-row-ltr" role="row">
<tr id="10" class="ui-widget-content jqgrow ui-row-ltr" role="row">
<tr id="10" class="ui-widget-content jqgrow ui-row-ltr" role="row">
Note that the <tr id=”10″> is repeating. This happens when I put the rowNum as 10. If I change the rowNum to 3, the <tr id=”3″> will be created twice.
The source of the problem is that you don’t include the
idinformation in the data which you posted. Moreover you use “retro” versions of jQuery and jqGrid. I recommend you to use jQuery 1.6.2 and jqGrid 4.1.2. Starting with the version 3.8.2 was introduced $.jgrid.randId() method which are used currently in many places. I hope that the problem are already fixed in the last version of jqGrid.In any way if you would add
idattribute to the<row>element of your data the problem should not exist even if you would continue to use old version of jqGrid.