更新:带有分页器的 JQGrid,行号增加时最后一行的表 ID 重复一次
我的 JQGrid 有一个(奇怪的?)问题。我正在使用本地 XML 填充网格。我设置了一个 JQGrid rowNum:10 和 rowList:[10,20,30,40,50]。 我有12条记录。 数据(最初 10 个)已完美加载到网格中,表 ID 为 ["1", "2", "3", "4", "5", "6", "7", "8", “9”,“10”]。当我将 rowList 更改为 20 时,表 ID 为 ["1", "2", "3", "4", "5", "6", "7", "8", "9", " 10”、“10”、“11”]。数字 10 显示两次。 以前有人见过这个错误吗? 提前致谢。
JQuery 版本:1.4.2
jqGrid 版本:3.8.1
代码片段
我们这里的 xml 是:
<根><行><行><单元格>prasanth<单元格>kumar<行><单元格>prasanth<单元格>库马尔<行><单元格>prasanth
JQGrid 由以下代码定义:
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 });
当我将 rowlist 更改为 20 后签入 firebug 时,将创建如下行:
<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">
请注意,正在重复。当我将 rowNum 设置为 10 时会发生这种情况。如果我将 rowNum 更改为 3,则 将被创建两次。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题的根源在于您没有在发布的数据中包含
id
信息。此外,您还使用“复古”版本的 jQuery 和 jqGrid。我建议您使用 jQuery 1.6.2 和 jqGrid 4.1.2。从版本 3.8.2 开始引入了 $.jgrid.randId() 方法,目前在很多地方使用。我希望这个问题已经在 jqGrid 的最新版本中得到解决。无论如何,如果您将
id
属性添加到数据的|
元素,即使您继续使用旧版本的 jqGrid,问题也不应该存在。The source of the problem is that you don't include the
id
information 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
id
attribute to the<row>
element of your data the problem should not exist even if you would continue to use old version of jqGrid.