如何从响应中加载存储而不在存储中指定url

时间:2012-07-20 12:43:10

标签: extjs4

如何从已经拥有的响应加载数据以及如何读取到达的响应并使用该响应数据在extjs中加载存储。我在这里发布了我的回复。提前谢谢。

{"preparedSandData":[{"preparedsandId":57,"activeClay":1,"afs":1,"compactability":1,"date":"12-10-2012 12:00:00 AM","deadClay":1,"gcs":1,"loi":1,"moisture":1,"quantity":1,"shatterIndex":1,"shearStrength":1,"shift":"Morning","splittingStrength":1,"temperature":1,"time":"12-10-2012 12:00:00 AM","totalClay":1,"username":"manoj","sampleId":23},{"preparedsandId":58,"activeClay":2,"afs":2,"compactability":2,"date":"12-11-2012 12:00:00 AM","deadClay":2,"gcs":2,"loi":2,"moisture":2,"quantity":2,"shatterIndex":2,"shearStrength":2,"shift":"Morning","splittingStrength":2,"temperature":2,"time":"12-11-2012 12:00:00 AM","totalClay":2,"username":"manoj","sampleId":23},{"preparedsandId":59,"activeClay":3,"afs":3,"compactability":3,"date":"12-12-2012 12:00:00 AM","deadClay":3,"gcs":3,"loi":3,"moisture":3,"quantity":3,"shatterIndex":3,"shearStrength":3,"shift":"Morning","splittingStrength":3,"temperature":3,"time":"12-12-2012 12:00:00 AM","totalClay":3,"username":"manoj","sampleId":23},{"preparedsandId":60,"activeClay":4,"afs":4,"compactability":4,"date":"12-13-2012 12:00:00 AM","deadClay":4,"gcs":4,"loi":4,"moisture":4,"quantity":4,"shatterIndex":4,"shearStrength":4,"shift":"Morning","splittingStrength":4,"temperature":4,"time":"12-13-2012 12:00:00 AM","totalClay":4,"username":"manoj","sampleId":23},{"preparedsandId":61,"activeClay":5,"afs":5,"compactability":5,"date":"12-14-2012 12:00:00 AM","deadClay":5,"gcs":5,"loi":5,"moisture":5,"quantity":5,"shatterIndex":5,"shearStrength":5,"shift":"Morning","splittingStrength":5,"temperature":5,"time":"12-14-2012 12:00:00 AM","totalClay":5,"username":"manoj","sampleId":23},{"preparedsandId":62,"activeClay":6,"afs":6,"compactability":6,"date":"12-15-2012 12:00:00 AM","deadClay":6,"gcs":6,"loi":6,"moisture":6,"quantity":6,"shatterIndex":6,"shearStrength":6,"shift":"Morning","splittingStrength":6,"temperature":6,"time":"12-15-2012 12:00:00 AM","totalClay":6,"username":"manoj","sampleId":23},{"preparedsandId":63,"activeClay":7,"afs":7,"compactability":7,"date":"12-16-2012 12:00:00 AM","deadClay":7,"gcs":7,"loi":7,"moisture":7,"quantity":7,"shatterIndex":7,"shearStrength":7,"shift":"Morning","splittingStrength":7,"temperature":7,"time":"12-16-2012 12:00:00 AM","totalClay":7,"username":"manoj","sampleId":23},{"preparedsandId":64,"activeClay":8,"afs":8,"compactability":8,"date":"12-17-2012 12:00:00 AM","deadClay":8,"gcs":8,"loi":8,"moisture":8,"quantity":8,"shatterIndex":8,"shearStrength":8,"shift":"Morning","splittingStrength":8,"temperature":8,"time":"12-17-2012 12:00:00 AM","totalClay":8,"username":"manoj","sampleId":23},{"preparedsandId":65,"activeClay":9,"afs":9,"compactability":9,"date":"12-18-2012 12:00:00 AM","deadClay":9,"gcs":9,"loi":9,"moisture":9,"quantity":9,"shatterIndex":9,"shearStrength":9,"shift":"Morning","splittingStrength":9,"temperature":9,"time":"12-18-2012 12:00:00 AM","totalClay":9,"username":"manoj","sampleId":23},{"preparedsandId":66,"activeClay":10,"afs":10,"compactability":10,"date":"12-19-2012 12:00:00 AM","deadClay":10,"gcs":10,"loi":10,"moisture":10,"quantity":10,"shatterIndex":10,"shearStrength":10,"shift":"Morning","splittingStrength":10,"temperature":10,"time":"12-19-2012 12:00:00 AM","totalClay":10,"username":"manoj","sampleId":23},{"preparedsandId":67,"activeClay":11,"afs":11,"compactability":11,"date":"12-20-2012 12:00:00 AM","deadClay":11,"gcs":11,"loi":11,"moisture":11,"quantity":11,"shatterIndex":11,"shearStrength":11,"shift":"Morning","splittingStrength":11,"temperature":11,"time":"12-20-2012 12:00:00 AM","totalClay":11,"username":"manoj","sampleId":23},{"preparedsandId":68,"activeClay":12,"afs":12,"compactability":12,"date":"12-21-2012 12:00:00 AM","deadClay":12,"gcs":12,"loi":12,"moisture":12,"quantity":12,"shatterIndex":12,"shearStrength":12,"shift":"Morning","splittingStrength":12,"temperature":12,"time":"12-21-2012 12:00:00 AM","totalClay":12,"username":"manoj","sampleId":23},{"preparedsandId":69,"activeClay":13,"afs":13,"compactability":13,"date":"12-22-2012 12:00:00 AM","deadClay":13,"gcs":13,"loi":13,"moisture":13,"quantity":13,"shatterIndex":13,"shearStrength":13,"shift":"Morning","splittingStrength":13,"temperature":13,"time":"12-22-2012 12:00:00 AM","totalClay":13,"username":"manoj","sampleId":23},{"preparedsandId":70,"activeClay":14,"afs":14,"compactability":14,"date":"12-23-2012 12:00:00 AM","deadClay":14,"gcs":14,"loi":14,"moisture":14,"quantity":14,"shatterIndex":14,"shearStrength":14,"shift":"Morning","splittingStrength":14,"temperature":14,"time":"12-23-2012 12:00:00 AM","totalClay":14,"username":"manoj","sampleId":23},{"preparedsandId":71,"activeClay":1,"afs":1,"compactability":1,"date":"12-10-2012 12:00:00 AM","deadClay":1,"gcs":1,"loi":1,"moisture":1,"quantity":1,"shatterIndex":1,"shearStrength":1,"shift":"Morning","splittingStrength":1,"temperature":1,"time":"12-10-2012 12:00:00 AM","totalClay":1,"username":"manoj","sampleId":0},{"preparedsandId":72,"activeClay":2,"afs":2,"compactability":2,"date":"12-11-2012 12:00:00 AM","deadClay":2,"gcs":2,"loi":2,"moisture":2,"quantity":2,"shatterIndex":2,"shearStrength":2,"shift":"Morning","splittingStrength":2,"temperature":2,"time":"12-11-2012 12:00:00 AM","totalClay":2,"username":"manoj","sampleId":0},{"preparedsandId":73,"activeClay":3,"afs":3,"compactability":3,"date":"12-12-2012 12:00:00 AM","deadClay":3,"gcs":3,"loi":3,"moisture":3,"quantity":3,"shatterIndex":3,"shearStrength":3,"shift":"Morning","splittingStrength":3,"temperature":3,"time":"12-12-2012 12:00:00 AM","totalClay":3,"username":"manoj","sampleId":0},{"preparedsandId":74,"activeClay":4,"afs":4,"compactability":4,"date":"12-13-2012 12:00:00 AM","deadClay":4,"gcs":4,"loi":4,"moisture":4,"quantity":4,"shatterIndex":4,"shearStrength":4,"shift":"Morning","splittingStrength":4,"temperature":4,"time":"12-13-2012 12:00:00 AM","totalClay":4,"username":"manoj","sampleId":0},{"preparedsandId":75,"activeClay":5,"afs":5,"compactability":5,"date":"12-14-2012 12:00:00 AM","deadClay":5,"gcs":5,"loi":5,"moisture":5,"quantity":5,"shatterIndex":5,"shearStrength":5,"shift":"Morning","splittingStrength":5,"temperature":5,"time":"12-14-2012 12:00:00 AM","totalClay":5,"username":"manoj","sampleId":0},{"preparedsandId":76,"activeClay":6,"afs":6,"compactability":6,"date":"12-15-2012 12:00:00 AM","deadClay":6,"gcs":6,"loi":6,"moisture":6,"quantity":6,"shatterIndex":6,"shearStrength":6,"shift":"Morning","splittingStrength":6,"temperature":6,"time":"12-15-2012 12:00:00 AM","totalClay":6,"username":"manoj","sampleId":0},{"preparedsandId":77,"activeClay":7,"afs":7,"compactability":7,"date":"12-16-2012 12:00:00 AM","deadClay":7,"gcs":7,"loi":7,"moisture":7,"quantity":7,"shatterIndex":7,"shearStrength":7,"shift":"Morning","splittingStrength":7,"temperature":7,"time":"12-16-2012 12:00:00 AM","totalClay":7,"username":"manoj","sampleId":0},{"preparedsandId":78,"activeClay":8,"afs":8,"compactability":8,"date":"12-17-2012 12:00:00 AM","deadClay":8,"gcs":8,"loi":8,"moisture":8,"quantity":8,"shatterIndex":8,"shearStrength":8,"shift":"Morning","splittingStrength":8,"temperature":8,"time":"12-17-2012 12:00:00 AM","totalClay":8,"username":"manoj","sampleId":0},{"preparedsandId":79,"activeClay":9,"afs":9,"compactability":9,"date":"12-18-2012 12:00:00 AM","deadClay":9,"gcs":9,"loi":9,"moisture":9,"quantity":9,"shatterIndex":9,"shearStrength":9,"shift":"Morning","splittingStrength":9,"temperature":9,"time":"12-18-2012 12:00:00 AM","totalClay":9,"username":"manoj","sampleId":0},{"preparedsandId":80,"activeClay":10,"afs":10,"compactability":10,"date":"12-19-2012 12:00:00 AM","deadClay":10,"gcs":10,"loi":10,"moisture":10,"quantity":10,"shatterIndex":10,"shearStrength":10,"shift":"Morning","splittingStrength":10,"temperature":10,"time":"12-19-2012 12:00:00 AM","totalClay":10,"username":"manoj","sampleId":0},{"preparedsandId":81,"activeClay":11,"afs":11,"compactability":11,"date":"12-20-2012 12:00:00 AM","deadClay":11,"gcs":11,"loi":11,"moisture":11,"quantity":11,"shatterIndex":11,"shearStrength":11,"shift":"Morning","splittingStrength":11,"temperature":11,"time":"12-20-2012 12:00:00 AM","totalClay":11,"username":"manoj","sampleId":0},{"preparedsandId":82,"activeClay":12,"afs":12,"compactability":12,"date":"12-21-2012 12:00:00 AM","deadClay":12,"gcs":12,"loi":12,"moisture":12,"quantity":12,"shatterIndex":12,"shearStrength":12,"shift":"Morning","splittingStrength":12,"temperature":12,"time":"12-21-2012 12:00:00 AM","totalClay":12,"username":"manoj","sampleId":0},{"preparedsandId":83,"activeClay":13,"afs":13,"compactability":13,"date":"12-22-2012 12:00:00 AM","deadClay":13,"gcs":13,"loi":13,"moisture":13,"quantity":13,"shatterIndex":13,"shearStrength":13,"shift":"Morning","splittingStrength":13,"temperature":13,"time":"12-22-2012 12:00:00 AM","totalClay":13,"username":"manoj","sampleId":0},{"preparedsandId":84,"activeClay":14,"afs":14,"compactability":14,"date":"12-23-2012 12:00:00 AM","deadClay":14,"gcs":14,"loi":14,"moisture":14,"quantity":14,"shatterIndex":14,"shearStrength":14,"shift":"Morning","splittingStrength":14,"temperature":14,"time":"12-23-2012 12:00:00 AM","totalClay":14,"username":"manoj","sampleId":0}],"success":true}

1 个答案:

答案 0 :(得分:0)

//Result being your response from the request
//you need to decode it
var response = Ext.decode(result.responseText);
var records = [];
Ext.Array.each(response.preparedSandData, function(recordData) {
    //each record needs to  be instantiated to a model  
    var record = Ext.ModelManager.create(recordData, '*ModelClass*');
    records.push(record);
});
//load all records at once
store.loadRecords(records);