【问题标题】:jqGrid data format and jsonReaderjqGrid数据格式和jsonReader
【发布时间】:2017-08-09 11:33:49
【问题描述】:

我有以下格式的数据,绑定时我的jqGrid 中有空行。我的数据类型应该是什么,或者如何避免使用jsonReader,以便它默认处理它。

我的网格结构是,

$("#UserReportGrid").jqGrid({

    datatype: 'local',
    data: data,
    colNames: colNames,
    colModel: colNames,
    localReader: {
    repeatitems: true,
    cell: "",
    id: 0, root: "data",
    },
    rowNum: 10,
    rowList: [10, 25, 50, 100],
    pager: '#GridPager',
    caption: "User Details",
    height: 'auto',
    sortname: 'SNo',
    gridview: true
});

我试过了,

JSON.parse(data) resulted in exception
JSON.parse(JSON.stringify(data))  resulted in same no records are displayed

【问题讨论】:

  • 只需从设置中删除 localReader 并确保您已在 colModel 中设置 key: true 以标识将充当 id 的列。数据应该是对象数组,你不需要 JSON.parse 它

标签: jquery jqgrid


【解决方案1】:

您的问题的原因是使用了错误的localReader 参数。您应该将其替换为

localReader: { id: "SNo" }

或者完全删除它并在SNo 列中添加key: true,如果您在colModel 中有列的话。

在不同版本的 jqGrid 和不同的分支(free jqGrid、商业 Guriddo jqGrid JS 和版本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    相关资源
    最近更新 更多