-
25 Apr 2012 11:55 AM #1
Store filter root property in nested JSON?
Store filter root property in nested JSON?
Hi,
I'm loading a store with JSON that looks like :
If I want to apply a filter to the store to get only items that have CONTENTGROUP of "2", what do I do? I've tried setting it on the store and the data won't load with it. Do I need to set the root on the filter?Code:{ "SUCCESS":true, "RESPONSE":{ "CONTENTOBJECTS":[ { "CONTENTGROUP":"1", "CONTENTTITLE":"promote test 1 title", "OBJECTID":"C49B8765-1C80-0001-EA62-1A031F8F262", }, { "CONTENTGROUP":"2", "CONTENTTITLE":"December Brings Measured Improvements in Southeast Economy", "OBJECTID":"C51E7E07-4860-0001-467B-E7361D97AC5", } ], "CONTENTGROUPS":[ "News", "Podcasts" ] } }
Here's the store:
Code:Ext.define('FRBAMobile.store.ContentObjects', { extend: 'Ext.data.Store', requires: [ 'FRBAMobile.model.ContentObject' ], config: { autoLoad: true, model: 'FRBAMobile.model.ContentObject', storeId: 'ContentObjects', proxy: { type: 'jsonp', url: 'http://devserver/mobileContent/', reader: { type: 'json', rootProperty: 'RESPONSE.CONTENTOBJECTS', successProperty: 'SUCCESS' } }, filters: [ { id: 'contentGroup1Filter', property: 'CONTENTGROUP', value: "1" } ] } });
-
27 Apr 2012 5:36 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
What does the model look like?
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.
-
27 Apr 2012 9:53 AM #3
Here 'tis:
Code:Ext.define('FRBAMobile.model.ContentObject', { extend: 'Ext.data.Model', config: { fields: [ { name: 'OBJECTID', type: 'string' }, { name: 'CONTENTTITLE', type: 'string' }, { allowNull: false, defaultValue: '1', name: 'CONTENTGROUP' }, { name: 'BODY' }, { name: 'MOBILEBODY' } ] } });
-
27 Apr 2012 10:45 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
What I am getting is if you have the filters, it has a count of 1. If you remove the filters config it has a count of 2 so looks like your code is working for me. The only thing I did was change the proxy from jsonp to ajax as I was just loading off a JSON file.
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