为什么我的小提琴表现不正常?

时间:2013-10-24 18:00:13

标签: javascript json extjs sencha-architect

我想要呈现为树的我的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"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

我想在jsonviewer.stack.hu中使用我的json渲染一个带有extJS的树

enter image description here

我试着用小提琴做这件事,但是无法做到这一点,有些事情对小提琴很奇怪:

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

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

1 个答案:

答案 0 :(得分:1)

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