gpt4 book ai didi

javascript - 使用 loadonce 时的 JQGrid 分组问题

转载 作者:行者123 更新时间:2023-11-28 08:26:50 26 4
gpt4 key购买 nike

第一次来...所以提前致谢。

我有一个 JQGrid 页面。这是我的 JQGrid(最新版本...昨天下载)设置:

$(function() {
$("#list").jqGrid({
caption: "My first grid",
url: "demo_data.php",
loadonce: true,
datatype: "xml",
mtype: "GET",
pager: "#pager",
height: "100%",
autowidth: true,
altRows: false,
rowTotal: 2000,
rowNum: 10000,
rowList: [10, 25, 50],
viewrecords: true,
autoencode: true,
colNames: ["Publisher", "First Name", "Last Name", "EMail"],
colModel: [
{name: "pid"},
{name: "fname"},
{name: "lname"},
{name: "email", summaryType:'count',summaryTpl:'<b>{0} Item(s)</b>'}
],
sortname: "pid",
sortorder: "desc",
grouping: true,
groupingView: {
groupField: ['pid'],
groupOrder: ['asc'],
groupCollapse : true,
groupText : ['<b>{0} - {1} Item(s)</b>'],
groupSummary : true
},
ignoreCase: true
});
$("#list").jqGrid('filterToolbar',{
stringResult: true,
searchOnEnter : false,
defaultSearch: "cn"
});
});

虽然 loadonce 为 true,但我在控制台上收到错误:

Uncaught TypeError: Cannot read property '0' of null

此错误会停止此代码行上的脚本:

if(!grdata[kk - offset]) { break; }

关于 GroupRender 函数。

当我将 loadonce 设置为 false 时,分组一切正常,但我失去了出色的客户端数据操作。

这是我作为数据发送的 XML 文件:

<rows>
<row id = '1'>
<cell></cell>DataA</cell>
<cell>NameA</cell>
<cell>LastNameA</cell>
<cell>EMail A</cell>
</row>
<row id = '2'>
<cell>DataA</cell>
<cell>NameB</cell>
<cell>LastNameB</cell>
<cell>EMail B</cell>
</row>
<row id = '1'>
<cell>DataB</cell>
<cell>NameAA</cell>
<cell>LastNameAA</cell>
<cell>EMail AA</cell>
</row>
<row id = '1'>
<cell>DataB</cell>
<cell>NameBB</cell>
<cell>LastNameBB</cell>
<cell>EMail BB</cell>
</row>
</rows>

预先感谢您的帮助:)

最佳答案

loadonce: true 似乎不适用于 grouping:true 如果数据类型是 xml

我也遇到了同样的问题,我通过将 url 属性调用的 PHP 页面更改为返回 json,然后将 datatype 属性更改为 json 来解决它。

关于javascript - 使用 loadonce 时的 JQGrid 分组问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22300665/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com