如何从商店获取价值字段

时间:2014-06-05 11:47:45

标签: extjs

我用ExtJS 3.4创建了一个商店,这是我的代码:

var itiStore = new Ext.data.JsonStore({
    root: 'getItiResultResult',
    fields: [
        {name: 'Arrival'},
        {name: 'ColumnsName'},
        {name: 'Error'},
        {name: 'Points', mapping: 'Points'},
        {name: 'La', mapping: 'Points.La'},
        {name: 'Lo', mapping: 'Points.Lo'},
        {name: 'Rows', mapping: 'Rows'},
        {name: "ChangeRowColor", mapping: 'Rows.ChangeRowColor'},
        {name: "CumDistance", mapping: 'Rows.CumDistance'},
        {name: "CumTime", mapping: 'Rows.CumTime'},
        {name: "Direction", mapping: 'Rows.Direction'},
        {name: "Distance", mapping: 'Rows.Distance'},
        {name: "La", mapping: 'Rows.La'},
        {name: "Lo", mapping: 'Rows.Lo'},
        {name: "RoadMap", mapping: 'Rows.RoadMap'},
        {name: "Step", mapping: 'Rows.Step'},
        {name: "Time", mapping: 'Rows.Time'},
        {name: "dCumDist", mapping: 'Rows.dCumDist'},
        {name: "dCumTime", mapping: 'Rows.dCumTime'},
        {name: 'Start'},
        {name: 'TotDistance'},
        {name: 'TotTime'}
    ]
});

我过去常常展示我的商店:

itiStore.loadData(Ext.decode(response.responseText), false); console.log(JSON.parse(response.responseText));

我怎样才能获得该领域的价值' RoadMap'并恢复它以显示它。

先谢谢你们的帮助。

1 个答案:

答案 0 :(得分:0)

商店包含许多记录,因此如果您需要其中一个记录,那么:

var record = store.getAt(22); // or other way of getting a record
var roadMap = record.get('RoadMap'); 

如果您希望商店仅包含RoadMap,则创建仅包含该字段的另一个商店,一旦您解码了JSON响应,就会使用解码数据加载这两个商店。