-
4 Jul 2010 11:29 PM #1
Bug? JsonStore - panelgrid field mappings working in browser not in air?
Bug? JsonStore - panelgrid field mappings working in browser not in air?
The mapping of "emails.value" appears to work fine in firefox but not in air?Code:var mydata = '{"items":[{"name":{"givenName":"John","formatted":"John Sim","familyName":"Sim"},"id":"simj01","displayName":"John Sim","guid":"01CD2D900FE711DFBFAFED8A0AD5D910","addresses":[],"connected":"true","organizations":{"empty":false},"emails":{"value":"me@me.co.uk","empty":false,"type":"WORK","primary":"true"}]}'; //create a datamodel to display the JSON var store = new Ext.data.JsonStore({ // store configs autoDestroy: true, storeId: 'forumStore', //data:Ext.encode(mydata), data:Ext.decode(mydata), // reader configs root: 'items', idProperty: 'id', fields: [{name:'UID', mapping:'id'}, {name:'displayName', mapping:'displayName'}, {name:'email', mapping:'emails.value'}] });
UID and displayName appear within the grid in AIR.
Code://create the Grid var grid = new Ext.grid.GridPanel({ store: store, columns: [ {id: 'uid', header: 'UID', width: 80, sortable: true, dataIndex: 'UID'}, {id: 'conn', header: 'Connection', width: 80, sortable: true, dataIndex: 'displayName'}, {id: 'email', header: 'email', width: 80, sortable: true, dataIndex: 'email'} ], stripeRows: true, autoExpandColumn: 'conn', height: 200, width: 400, title: 'My Connections', viewConfig: {scrollOffset: 2} }); grid.render('connections');
can anyone see what stupid mistake I've made?
Thanks
-
4 Jul 2010 11:58 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
It should work if you create your store directly, before Ext.onReady.
(JsonReader.createAccessor uses new Function() which is only allowed in Air at startup)
-
5 Jul 2010 1:11 AM #3
-
5 Jul 2010 2:37 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
Don't you get an error in Air when you put your store inside Ext.onReady?
ps. You do need to put "grid.render('connections')" inside Ext.onReady.
-
5 Jul 2010 3:11 AM #5
I have completely removed Ext.onReady now; the grid display still works and shows UID and displayName but still not the email.value -- "me@me.co.uk".
In Aptana 2.0.4 I select debug to run and start the air application but I get no errors?
I still don`t understand why the store has to load outside of Ext.onReady?
How would Ext.Ajax.request work to put data into the store for a generated grid if it was event driven by an on click event?
These are the scripts I call within the head
I noticed there was a bug jsonReader bug in 3.2.1 that affects Ext.data.ArrayStoreHTML Code:<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" /> <link rel="stylesheet" type="text/css" href="extjs/air/css/ext-air.css" /> <script type="text/javascript" src="air/AIRAliases.js"></script> <script type="text/javascript" src="air/AIRIntrospector.js"></script> <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="extjs/ext-all-debug.js"></script> <script type="text/javascript" src="extjs/ext-air.js"></script>
Could this be a similar issue?
I have also tried to retrieve name.givenName but it does not return the value?Code://data {"items":[{" name":{ "givenName":"John", "formatted":"John Sim", "familyName":"Sim"}, "id":"simj01", "displayName":"John Sim", "guid":"01CD2D900FE711DFBFAFED8A0AD5D910", "addresses":[], "connected":"true", "organizations":{ "empty":false}, "emails":{ "value":"me@me.co.uk", "empty":false, "type":"WORK", "primary":"true"} ]} } //fields fields: [{ name:'email', mapping:'emails.value' }] //grid mapping { id: 'email', header: 'email', width: 80, sortable: true, dataIndex: 'email' }
only the root values seem to be returned ie id, displayName, guid etc..Last edited by SlashEMc2k; 5 Jul 2010 at 3:15 AM. Reason: update format
-
5 Jul 2010 4:04 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
No, loading the store can happen anywhere. It's the call to JsonReader.buildExtractors (which calls Json.createAccessor) that needs to be outside Ext.onReady.
For security reasons, Air has very strict rules on when eval() and new Function() are allowed (only when the script is loading - not in event handlers).
ps. You'll run into the same problem when you start using DateFields (all possible dateFormats will have to be precompiled at startup).
-
5 Jul 2010 4:37 AM #7
Thanks Condor; that makes sense

So if my understanding is right this should work -
Code:var storeSetup = new Ext.data.JsonStore({ // store configs autoDestroy: true, storeId: 'forumStore', // reader configs root: 'items', idProperty: 'id', fields: [{ name: 'UID', mapping: 'id' }, { name: 'displayName', mapping: 'displayName' }, { name: 'email', mapping: 'emails.value' }] }); Ext.onReady(function(){ var mydata = '{"items":[{"name":{"givenName":"John","formatted":"John Sim","familyName":"Sim"},"id":"simj01","displayName":"John Sim","guid":"01CD2D900FE711DFBFAFED8A0AD5D910","addresses":[],"connected":"true","organizations":{"empty":false},"emails":{"value":"me@me.co.uk","empty":false,"type":"WORK","primary":"true"}]}'; var dataStore = new Ext.data.Store({ autoLoad: true, data: Ext.decode(mydata), reader: storeSetup }); var grid = new Ext.grid.GridPanel({ store: dataStore, columns: [{ id: 'uid', header: 'UID', width: 80, sortable: true, dataIndex: 'UID' }, { id: 'conn', header: 'Connection', width: 80, sortable: true, dataIndex: 'displayName' }, { id: 'email', header: 'email', width: 80, sortable: true, dataIndex: 'email' }], stripeRows: true, autoExpandColumn: 'conn', height: 200, width: 400, title: 'My Connections', viewConfig: { scrollOffset: 2 } }); });
-
5 Jul 2010 4:54 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
The same rules apply to Ext.decode!
(unless you set Ext.USE_NATIVE_JSON = true)
-
5 Jul 2010 7:03 AM #9
Thanks for the update. Just reviewing some bugs I put in.. mybad..
That did the trick!!! Thanks so much for the help
Similar Threads
-
Simple Tasks Air App Not Working??
By dawesi in forum Ext.air for Adobe AIRReplies: 2Last Post: 25 Jun 2010, 10:20 PM -
Getting Ext 3.2 working in Adobe AIR
By alexbariv in forum Ext.air for Adobe AIRReplies: 2Last Post: 20 Apr 2010, 6:50 AM -
[Solved] Newbie - PanelGrid
By pw81 in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 6 Aug 2009, 11:50 AM -
AIR : Ext.Ajax.request not working
By ghyster in forum Ext.air for Adobe AIRReplies: 10Last Post: 6 Mar 2008, 6:01 AM -
[1.1RC1] JsonStore's proxy config - doc bug or source bug?
By mystix in forum Ext 1.x: BugsReplies: 2Last Post: 19 Aug 2007, 11:27 AM


Reply With Quote