-
25 Jun 2012 2:08 PM #1
Answered: Manipulate data from Proxy before store
Answered: Manipulate data from Proxy before store
I have an older service that I can't change.
It's passing me some data not in array.
So what I need to do is take the data I'm getting and change it to an array before adding it to the store.
Example:
I'm getting from the service in json:
{ "id": "1234",
"isAdmin": true
}
I need to change it to this before it gets stored:
[{ "id": "1234",
"isAdmin": true
}]
So where would I go about this?
Right now my proxy looks like this.
proxy: {
type:'ajax',
url: '/service/etc.',
reader:'json'
}
I was thinking Ext.data.proxy.Memory, some guidance with doing this would be great!
Thanks for the help in advance!!
-
Best Answer Posted by scottmartin
You can use listeners to determine when to change your data.
Regards,Code:listeners: { beforeLoad: function(store, operation){ // 1st; no data items console.log('beforeLoad'); console.log(store.data.items); }, dataChanged: function(store){ // 2nd; data items populated, controls still empty console.log('dataChanged'); console.log(store.data.items); }, load: function(store, records, success){ // 3rd; data items populate, controls show data console.log('load'); console.log(store.data.items); } } });
Scott.
-
28 Jun 2012 1:31 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
You can use listeners to determine when to change your data.
Regards,Code:listeners: { beforeLoad: function(store, operation){ // 1st; no data items console.log('beforeLoad'); console.log(store.data.items); }, dataChanged: function(store){ // 2nd; data items populated, controls still empty console.log('dataChanged'); console.log(store.data.items); }, load: function(store, records, success){ // 3rd; data items populate, controls show data console.log('load'); console.log(store.data.items); } } });
Scott.


Reply With Quote