extJS: reading a nested JSON

前端 未结 2 1082
感动是毒
感动是毒 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:53

    I was looking to do the same thing, but have one of the nested items be a field in my chart. This post kept coming up, so I thought it might be helpful to see what I did to solve the chart issue. The key to solving it is knowing that the label config exists: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.chart.Label. Using that you can override the default render of what you pass in. In this example the field is "key" (Not shown here, but my model is using the default type for 'key' (ie., not string)). The key object gets passed to renderer. Using function(t), I can now access that object like javascript and pass back the name under the object.

     json
        key : { 
                wholePath : "c:/.../fileName.txt",
                fileName : "fileName.txt",
            }
      code:
        axes: [
        {
            title: 'Values',
            type: 'Numeric',
            position: 'left',
            fields: ['value'],
            minimum: 0,
            maximum: 100,
            minorTickSteps: 1
        },
        {
            title: 'File Name',
            type: 'Category',
            position: 'bottom',
            fields: ['key'],
            label: {
                renderer: function(t) {
                   var fileName = t.name;
                   return fileName;
                }
            }
        }
    

提交回复
热议问题