-
18 Jan 2013 2:50 PM #1
Unanswered: Load data from REST where response is string
Unanswered: Load data from REST where response is string
Hello guys.
I defined a view that extends from Ext.List. I created a store and a Model for this.
My Store:
My Model:Code:Ext.define('ConnectMobile.store.Groups', { extend: 'Ext.data.Store', requires: [ 'Ext.data.proxy.Ajax' ], config: { model: 'ConnectMobile.model.Groups', autoLoad: true, proxy: { type: 'ajax', url: 'url of the REST server', actionMethods: { read: 'POST' }, reader: { type: 'json', rootProperty: 'result', } } } });
My Ext.List view:Code:Ext.define('ConnectMobile.model.Groups', { extend: 'Ext.data.Model', config: { clientIdProperty: 'guid', fields: [ {name: 'guid', type: 'int'}, {name: 'owner_guid', type: 'int'}, {name: 'container_guid', type: 'int'}, {name: 'access_id', type: 'int'}, {name: 'name', type: 'string'}, {name: 'picture', type: 'string'} ] } });
My ContainerPanel:Code:Ext.define('ConnectMobile.view.GroupsList', { extend: 'Ext.List', xtype: 'connectgroupslist', config: { itemCls: 'groups-list-item', // This is a test template itemTpl: '<div class="connect-left"><span class="title">{name}</span><span class="status">Open</span></div><div class="connect-right activity">2</div>', store: 'Groups', layout: 'fit' } });
My listview is in a ContainerPanel.Code:Ext.define('ConnectMobile.view.GroupsContainer', { extend: 'Ext.navigation.View', xtype: 'connectgroupscontainer', requires: ['ConnectMobile.view.GroupsList'], config: { fullscreen: true, navigationBar : { docked : 'top', items : [ { text : 'Sair', align : 'right', handler: function (obj) { obj.up('connectgroupscontainer').onLogoutButtonTap(); }, scope: this } ] }, items: [ { title: 'Grupos', xtype: 'connectgroupslist' } ] } });
My problem is that my proxy Store is a rest and returns:
When I define rootProperty: 'result', the data is not loaded in Store.Code:{ status: int, result: json string }
What should I do to load the Store data correctly?
The result comes like this:
The data I need are in result.data.groups, but result is a stringCode:{ data: { error: bool, errorMsg: string, total: int, groups: array } }
-
20 Jan 2013 8:13 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,640
- Vote Rating
- 435
- Answers
- 3106
So it's like this:
and notCode:{ status : 1, result : '[...]' }
Notice the quote in the first one.Code:{ status : 1, result : [...] }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Jan 2013 3:06 PM #3
Exactly, it's a string, not an array neither a json
-
21 Jan 2013 3:43 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,640
- Vote Rating
- 435
- Answers
- 3106
It's thinking it's a string, it really has to be an array to work
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote