jqGrid 为空,即使寻呼机显示结果

发布于 2024-12-06 19:08:50 字数 1374 浏览 1 评论 0原文

我正在从 jqGrid 3.6.3 升级 -> 4.1.2.

升级后,即使寻呼机显示正确的结果数量(本例中为 6),网格也始终显示为空。我可以看到 JSON 正在被检索并且是有效的。

不会显示任何错误,也不会向 JavaScript 控制台写入任何内容。 如果我挂接到 loadComplete 事件,它就会触发 - 并且 grid.getDataIDs() 返回一个空数组 - 就好像没有数据一样。

这是正在传输的 JSON(使用 JSONLint 格式化)。它是正确格式化的 JSON &通过 JSONLint 验证:

{
    "pageCount": "1",
    "pageSize": "15",
    "pageNumber": "1",
    "itemCount": "6",
    "items": [
        {
            "Id": "1",
            "Name": "Administrator"
        },
        {
            "Id": "3",
            "Name": "asfasfassf"
        },
        {
            "Id": "6",
            "Name": "askjdhajksdk sh"
        },
        {
            "Id": "2",
            "Name": "fg"
        },
        {
            "Id": "5",
            "Name": "test"
        },
        {
            "Id": "4",
            "Name": "sa afasf saf"
        }
    ]
}

这是我传递给 jqGrid 的 jqGrid 选项的相关部分:

{
    datatype: 'json',
    jsonReader: {
        root: 'items',
        id: '0',
        repeatitems: false,
        page: 'pageNumber',
        total: 'pageCount',
        records: 'itemCount'
    },
    mtype: 'POST',
    ...
};

我已经在互联网上搜索了答案,但没有运气。有人有建议吗?!

请参阅下面我传递给 jqGrid(options) 的选项对象的屏幕截图:

jqgrid options object

提前致谢! !

I'm upgrading from jqGrid 3.6.3 -> 4.1.2.

After upgrading the grid always displays empty, even though the pager shows the correct number of results (6 in this case). I can see that the JSON is being retrieved and is valid.

No error is displayed, and nothing is written to the javascript console.
If I hook into the loadComplete event, it fires -- and grid.getDataIDs() returns an empty array - as if there were no data.

Here is the JSON being transmitted (formatted with JSONLint). It is properly formatted JSON & passes JSONLint validation:

{
    "pageCount": "1",
    "pageSize": "15",
    "pageNumber": "1",
    "itemCount": "6",
    "items": [
        {
            "Id": "1",
            "Name": "Administrator"
        },
        {
            "Id": "3",
            "Name": "asfasfassf"
        },
        {
            "Id": "6",
            "Name": "askjdhajksdk sh"
        },
        {
            "Id": "2",
            "Name": "fg"
        },
        {
            "Id": "5",
            "Name": "test"
        },
        {
            "Id": "4",
            "Name": "sa afasf saf"
        }
    ]
}

Here is the relevant portion of the jqGrid options that I am passing into jqGrid:

{
    datatype: 'json',
    jsonReader: {
        root: 'items',
        id: '0',
        repeatitems: false,
        page: 'pageNumber',
        total: 'pageCount',
        records: 'itemCount'
    },
    mtype: 'POST',
    ...
};

I have scoured the interwebs for an answer, but no luck. Does anyone have a suggestion?!

See below a screenshot of the options object that I am passing into jqGrid(options):

jqgrid options object

Thanks in advance!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千里故人稀 2024-12-13 19:08:50

cell: '' 添加到您的 jsonReader:

jsonReader: {
    root: 'items',
    id: '0',
    repeatitems: false,
    page: 'pageNumber',
    total: 'pageCount',
    records: 'itemCount',
    cell: ''
}

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retriving_data#json_data

默认情况下,jsonReader 的cell 选项设置为“cell”,这意味着您的数据需要采用如下格式:

{
    "pageCount": "1",
    "pageSize": "15",
    "pageNumber": "1",
    "itemCount": "6",
    "items": [
        {
            "Id": "1",
            "cell": ["Administrator"]
        },
        {
            "Id": "3",
            "cell": ["asfasfassf"]
        }
    ]
}

另外,请查看 v3.6.4 到 v3.6.5 的升级指南:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:upgrade_from_3.6.4_to_3.6.5

Add cell: '' to your jsonReader:

jsonReader: {
    root: 'items',
    id: '0',
    repeatitems: false,
    page: 'pageNumber',
    total: 'pageCount',
    records: 'itemCount',
    cell: ''
}

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data

By default, the jsonReader's cell option is set to "cell", which would mean your data would need to be formatted like this:

{
    "pageCount": "1",
    "pageSize": "15",
    "pageNumber": "1",
    "itemCount": "6",
    "items": [
        {
            "Id": "1",
            "cell": ["Administrator"]
        },
        {
            "Id": "3",
            "cell": ["asfasfassf"]
        }
    ]
}

Also, take a look at the upgrade guide for v3.6.4 to v3.6.5: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:upgrade_from_3.6.4_to_3.6.5

橘香 2024-12-13 19:08:50

我解决了问题&该问题与 JSON 完全无关。

升级到 jqGrid 4.1.2 后,我发现我的网格表需要有一个 id 属性。不幸的是,我在桌子上设置了一个无效的ID(不小心,里面有空格)。

一旦我修复了表格的 id 属性,网格就开始正确渲染。

感谢您的回答!

I solved the problem & the issue was completely unrelated to JSON.

After upgrading to jqGrid 4.1.2 I found that my grid table needed to have an id attribute. Unfortunately, I had set an invalid ID on the table (it, by accident, had spaces in it).

Once I fixed the table's id attribute, the grid started rendering correctly.

Thanks for your answers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文