开发者

How to get server data from a remotely loaded store

I am using a GroupingStore to load data into a grid, data is loaded from server and read via a JSON reader. Here is the releveant code

var reader = new Ext.data.JsonReader({
    successProperty: 'success',
    idProperty: 'id',
    root: 'data',
    messageProperty: 'message'  
}, [
    {name: 'id'},
    {name: 'creator'},
    {name: 'first_name', allowBlank: false},
    {name: 'last_name', allowBlank: false}
]);开发者_Python百科

var store = new Ext.data.GroupingStore({
    id: 'person',
    proxy: proxy,
    reader: reader,
    groupField:'creator',
    sortInfo:{field: 'first_name', direction: "ASC"}
});

It is correctly being loaded into grid, but with this data I want to send some more data, which is not realted to grid but will save me a trip to server. So is there anyway I can access the orginal data returned from server?

I have tried using a callback in load

store.load({'callback':loadCallback})

but data in loadCallback is only list of records not orginal data.

Edit: a example from server i return {'form_items':[ ], 'data': [] }, data node is used as root of store and contains row for grid, i want to access form_items or actually the the orginal data which server returned to the store.


I have found a way to do it in load callback by directly accessing the store.reader.jsonData

e.g.

store.load({'callback':function(a,b,c){
   console.log(store.reader.jsonData)
 }});


It sounds like you want access to the original response from the server when the store is finished loading. Try this (untested) code.

store.proxy.on('onread', function(a, o, response) {
  var data = Ext.util.JSON.encode(response.responseText);
  console.dir(data.form_items);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜