jqgrid 树阅读器不工作

发布于 2024-11-18 18:11:09 字数 2658 浏览 3 评论 0原文

我的示例 Json 对象如下所示:

{
    "o": [
        {
            "level": 0,
            "outlineItemId": 8,
            "parentItemId": null,
            "parentItem": null,
            "order": 0,
            "text": "section 1",
            "isLeaf": "false",
            "expanded": "true"
        },
        {
            "level": 1,
            "outlineItemId": 9,
            "parentItemId": 8,
            "parentItem": {
                "level": 0,
                "outlineItemId": 8,
                "parentItemId": null,
                "parentItem": null,
                "order": 0,
                "text": "section 1",
                "isLeaf": "false",
                "expanded": "true"
            },
            "order": 0,
            "text": "sub 1",
            "isLeaf": "false",
            "expanded": "true"
        },
        {
            "level": 2,
            "outlineItemId": 10,
            "parentItemId": 9,
            "parentItem": {
                "level": 1,
                "outlineItemId": 9,
                "parentItemId": 8,
                "parentItem": {
                    "level": 0,
                    "outlineItemId": 8,
                    "parentItemId": null,
                    "parentItem": null,
                    "order": 0,
                    "text": "section 1",
                    "isLeaf": "false",
                    "expanded": "true"
                },
                "order": 0,
                "text": "sub 1",
                "isLeaf": "false",
                "negateDevice": null,
                "expanded": "true"
            },
            "order": 0,
            "text": "sub sub 1",
            "isLeaf": "true",
            "expanded": "true"
        }
    ]
}

早些时候,当树配置为:

treeReader: {
    level_field: "level",
        parent_id_field: "parentItemId",
        leaf_field: "isLeaf",
        expanded_field: "expanded"
},

我显示了正确的缩进和图像图标,但是当 json obj 始终具有“expanded”:“true”时,它们没有展开,所以我尝试了以下代码。

treeReader: {
    level_field: "o.level",
        parent_id_field: "o.parentItemId",
        leaf_field: "o.isLeaf",
        expanded_field: "o.expanded"
},

现在我没有得到图像图标,之前展开的树现在是平的。

我的 Json 阅读器以防万一我搞砸了..

    jsonReader: {
        root: 'o',
        id: 'o.outlineItemId',
        parentItemId: 'o.parentItem.outlineItemId',
        text: 'o.text',
        repeatitems: false,
        page:  function(obj) { return 1; },
        total: function(obj) { return 1; },
        records: function(obj) { return obj.o.length; },
      },

任何帮助将不胜感激。 沙阿

My sample Json object is shown below:

{
    "o": [
        {
            "level": 0,
            "outlineItemId": 8,
            "parentItemId": null,
            "parentItem": null,
            "order": 0,
            "text": "section 1",
            "isLeaf": "false",
            "expanded": "true"
        },
        {
            "level": 1,
            "outlineItemId": 9,
            "parentItemId": 8,
            "parentItem": {
                "level": 0,
                "outlineItemId": 8,
                "parentItemId": null,
                "parentItem": null,
                "order": 0,
                "text": "section 1",
                "isLeaf": "false",
                "expanded": "true"
            },
            "order": 0,
            "text": "sub 1",
            "isLeaf": "false",
            "expanded": "true"
        },
        {
            "level": 2,
            "outlineItemId": 10,
            "parentItemId": 9,
            "parentItem": {
                "level": 1,
                "outlineItemId": 9,
                "parentItemId": 8,
                "parentItem": {
                    "level": 0,
                    "outlineItemId": 8,
                    "parentItemId": null,
                    "parentItem": null,
                    "order": 0,
                    "text": "section 1",
                    "isLeaf": "false",
                    "expanded": "true"
                },
                "order": 0,
                "text": "sub 1",
                "isLeaf": "false",
                "negateDevice": null,
                "expanded": "true"
            },
            "order": 0,
            "text": "sub sub 1",
            "isLeaf": "true",
            "expanded": "true"
        }
    ]
}

Earlier when the tree was configured as:

treeReader: {
    level_field: "level",
        parent_id_field: "parentItemId",
        leaf_field: "isLeaf",
        expanded_field: "expanded"
},

I was displaying the correct indentation and image icons, however they were not expanded when the json obj always had "expanded":"true" so i tried the below code.

treeReader: {
    level_field: "o.level",
        parent_id_field: "o.parentItemId",
        leaf_field: "o.isLeaf",
        expanded_field: "o.expanded"
},

Now I am not getting the Image icons and the tree which was expanded earlier is now flat.

My Json reader just in case i goofed up..

    jsonReader: {
        root: 'o',
        id: 'o.outlineItemId',
        parentItemId: 'o.parentItem.outlineItemId',
        text: 'o.text',
        repeatitems: false,
        page:  function(obj) { return 1; },
        total: function(obj) { return 1; },
        records: function(obj) { return obj.o.length; },
      },

Any help will be appreciated.
Shah

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

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

发布评论

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

评论(1

一江春梦 2024-11-25 18:11:09

知道了!

对于读者来说,我必须包含 cell:'' 并删除 o。参考。并在 json 对象中加载:true。

Got it!

For the reader i had to include cell:'' and remove the o. references. and also loaded:true in the json object.

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