extJS: reading a nested JSON

前端 未结 2 1060
感动是毒
感动是毒 2021-01-22 06:25

I have a pretty nested JSON coming from a ldap_search() call. I would like to use this information to populate an ExtJS ComboBox, but I am facing some troubles with the reader.

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 06:47

    Yep, that JSON structure is not going to work straight away with standard ExtJS JSONReader. Take a look at this example taken from the ExtJS API documentation on how the JSON should look like.

    {
        results: 2000, // Reader's configured totalProperty
        rows: [        // Reader's configured root
            // record data objects:
            { id: 1, firstname: 'Bill', occupation: 'Gardener' },
            { id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
            ...
        ]
    }
    

    Also, the root config option is required, you cannot leave it empty. In the above example your root would be "rows".

    You are probably going to need to parse that JSON of yours into a simpler format at first, before feeding it to the JSONReader.

提交回复
热议问题