【问题标题】:JQGrid grouping while using loadonce issue使用 loadonce 问题时 JQGrid 分组
【发布时间】:2014-03-10 12:52:50
【问题描述】:

这里是第一个计时器......所以提前谢谢。

我有一个 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 为真时,我在控制台上出现错误:

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>

提前感谢您的帮助:)

【问题讨论】:

    标签: javascript jquery xml jqgrid grouping


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-11
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 2011-04-17
      相关资源
      最近更新 更多