0

帮助任何人,我需要在我的商店中使用 JSON 数据。有人可以指出我的 jsonstore 配置有什么问题吗?我需要在我的图表中使用 rain_value 和 air_pressure 参数,但 JSON 中的“数据”不会设置为 root。

我的设备型号:

Ext.define('device', {
extend: 'Ext.data.Model',
config: {
    fields  : [
        {
            name : 'dev_id',
            type : 'int'
        },
        {   
            name : 'location'
        }
    ],
    hasMany : [
        {   
            model          : 'stationData',
            name           : 'data',
            associationKey : 'data'
        },
    ]
  }
});

我的 deviceData 模型:

Ext.define('stationData', {
extend : 'Ext.data.Model',
config : {
    fields     : [
        'dateTimeRead',
        'rain_value',
        'air_pressure'
    ]
}});

我的 jsonStore:

var store = new Ext.data.Store({
autoLoad  : true,
model     : 'device',
proxy     : {
    type   : 'ajax',
    url    : 'dataURL',
    reader: {
                type: 'json',
                root: 'data'
            },

}
});

JSON数据:

[{
    "dev_id": 171,
    "location": "Sample location",
    "province": "Sample Province",
    "cell_num": "0123456789",
    "posx": "longitude",
    "posy": "latitude",
    "elevation": "105",
    "battery": "LP",
    "region": "VI",
    "type_id": "AWS",
    "imei_num": "300234011463010",
    "is_ftp": false,
    "data": [{
        "dateTimeRead": "2013-11-14 11:45:32",
        "rain_value": "0.52",
        "rain_intensity": "19.3",
        "air_pressure": "1002.02",
        "wind_speed": "7.9",
        "air_humidity": "76.7",
        "solar_radiation": "-305363.70",
        "wind_direction": "327",
        "air_temperature": "29.2",
        "rain_cum": "238.07",
        "soil_moisture1": "8.88",
        "soil_temperature1": "28.7",
        "soil_moisture2": "6.37",
        "soil_temperature2": "27.6",
        "rain_duration": "180",
        "wind_speed_max": "14.1",
        "sunshine_count": "0",
        "sunshine_cum": "19286",
        "wind_direction_max": "18"
    }, {
        "dateTimeRead": "2013-11-14 11:30:32",
        "rain_value": "0.00",
        "rain_intensity": "0.0",
        "air_pressure": "1002.02",
        "wind_speed": "8.9",
        "air_humidity": "68.6",
        "solar_radiation": "-239488.50",
        "wind_direction": "322",
        "air_temperature": "30.2",
        "rain_cum": "237.55",
        "soil_moisture1": "8.91",
        "soil_temperature1": "28.5",
        "soil_moisture2": "6.72",
        "soil_temperature2": "27.6",
        "rain_duration": "0",
        "wind_speed_max": "15.1",
        "sunshine_count": "455",
        "sunshine_cum": "19286",
        "wind_direction_max": "10"
    }, {
        "dateTimeRead": "2013-11-14 11:15:32",
        "rain_value": "0.00",
        "rain_intensity": "0.0",
        "air_pressure": "1002.02",
        "wind_speed": "10.2",
        "air_humidity": "67.8",
        "solar_radiation": "251642.70",
        "wind_direction": "333",
        "air_temperature": "31.0",
        "rain_cum": "237.55",
        "soil_moisture1": "8.90",
        "soil_temperature1": "28.4",
        "soil_moisture2": "7.01",
        "soil_temperature2": "27.6",
        "rain_duration": "0",
        "wind_speed_max": "18.3",
        "sunshine_count": "900",
        "sunshine_cum": "18831",
        "wind_direction_max": "9"
    }]
}]
4

0 回答 0