1. #1
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Question Bug? JsonStore - panelgrid field mappings working in browser not in air?

    Bug? JsonStore - panelgrid field mappings working in browser 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'}]
    		});
    The mapping of "emails.value" appears to work fine in firefox but not in air?
    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

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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)

  3. #3
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Question


    Quote Originally Posted by Condor View Post
    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)
    Thanks Condor:: I took out the Ext.onReady. The code is held within the html head but still only UID and display name are showing, email field is blank?

    If I run the page in a browser with Ext.onReady in place the values are displayed?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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. #5
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Default


    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

    HTML 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>
    I noticed there was a bug jsonReader bug in 3.2.1 that affects Ext.data.ArrayStore
    Could this be a similar issue?

    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'
    }
    I have also tried to retrieve name.givenName but it does not return the value?
    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

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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).

  7. #7
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Default


    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
            }
        });
    });

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    The same rules apply to Ext.decode!

    (unless you set Ext.USE_NATIVE_JSON = true)

  9. #9
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Default


    Thanks for the update. Just reviewing some bugs I put in.. mybad..
    That did the trick!!! Thanks so much for the help

Similar Threads

  1. Simple Tasks Air App Not Working??
    By dawesi in forum Ext.air for Adobe AIR
    Replies: 2
    Last Post: 25 Jun 2010, 10:20 PM
  2. Getting Ext 3.2 working in Adobe AIR
    By alexbariv in forum Ext.air for Adobe AIR
    Replies: 2
    Last Post: 20 Apr 2010, 6:50 AM
  3. [Solved] Newbie - PanelGrid
    By pw81 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 6 Aug 2009, 11:50 AM
  4. AIR : Ext.Ajax.request not working
    By ghyster in forum Ext.air for Adobe AIR
    Replies: 10
    Last Post: 6 Mar 2008, 6:01 AM
  5. Replies: 2
    Last Post: 19 Aug 2007, 11:27 AM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar