1

我想渲染为树的 JSON 是

{
    "productOfferings": [
        {
            "text": "Mobile subscription with Internet access 2GB and iPad 32GB",
            "description": "Joors 2GB mobile broadband and iPad 32GB",
            "productOfferings": [
                {
                    "id": 5,
                    "text": "Ipad with 32 GB storage",
                    "description": "A iPad 32 GB Product Offering",
                    "productSpecification": {
                        "id": 5,
                        "text": "IPad",
                        "description": ""
                    }
                },
                {
                    "id": 8,
                    "text": "Mobile subscription with Sim Card and Internet access 2GB",
                    "description": "Mobile subscription with Sim Card and Internet access 2GB",
                    "productSpecification": {
                        "id": 9,
                        "text": "Mobile subscription with sim card and Internet access",
                        "description": "Mobile subscription with sim card and Internet access",
                        "productSpecifications": [
                            {
                                "id": 2,
                                "text": "Mobile subscription with Sim Card",
                                "description": "This is the classic Subscription product of a Mobile Network totally void of Services, so it can only be used for accessing a HPLMN. Simply put a MSISDN + SIM"
                            },
                            {
                                "id": 4,
                                "text": "Mobile Internet access",
                                "description": "This is a GPRS Service for a Mobile Network Access Product for accessing Internet"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

我想用 extJS 渲染一棵树,就像我在 jsonviewer.stack.hu 中的 json 一样

在此处输入图像描述

我试着用小提琴来做,但它做不到,而且小提琴有几件事很奇怪:

http://jsfiddle.net/niklasro/auBTH/24/

当我使根不可见时,它变成了两个根。很奇怪。并且无法设置 displayField,它必须具有名称“text”但我不能仅仅因为 extJS 而更改我的 json。我希望文本字段具有名称“名称”。而且我一直在尝试像 jsonviewer.stack 那样渲染 produtSpecification ,但如何做到这一点令人费解。你能帮助我吗?

4

1 回答 1

1

作为第一个提示,ID 在 JSON 中必须是唯一的:http: //my.jetscreenshot.com/6795/20131025-xarw-24kb

于 2013-10-25T12:53:49.603 回答