1. #21
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    OK, You've done well so far, but it's not advisable to use dots in field names (and the therefor the ColumnModel dataIndex properties that reference them) because the dataIndex is used as a javascript property name, and dots are significant - there's another thread posted today where someone got bitten just just this: http://extjs.com/forum/showthread.php?t=17046

    What you need to do is define a mapping in field definition configs for the fields that are pulled from within an inner property.

    Code:
        var electronicDevice = Ext.data.Record.create([
           { name : 'id'},  // property name within the row object is the same as the field name
           { name : 'model', mapping: 'properties.model'}, // mapping needed here because name != mapping
           { name : 'deviceType', mapping: 'properties.deviceType'},
           { name : 'netBandWidth', mapping: 'properties.netBandwidth'}
        ]);
        
        var reader = new Ext.data.JsonReader({
     	   root : "features",
     	   totalProperty : "total",
     	   id : "id"
        }, electronicDevice);
        
        var store = new Ext.data.Store({
           nocache : true,
           reader : reader,
           autoLoad : true,
    	   remoteSort : true,
    	   proxy : new Ext.data.HttpProxy({
    	       url : '/getjson?queryable=featureType&featureType=Electronic%20Device',
    	       method : 'GET'
    	   })
    	});
    
        var grid1 = new xg.GridPanel({
            ds: store,
            cm: new xg.ColumnModel([
            {id : 'id', header : "Feature Number", width: 8, dataIndex : 'id'},
            {header: "Model", width: 10, dataIndex: 'model'},
            {header: "Device Type", width: 10, dataIndex: 'deviceType'},
            {header: "Net Bandwidth", width: 10, dataIndex: 'netBandwidth'}
    
            ...
    The documentation for Ext.data.record.create explains this.

  2. #22
    Ext User
    Join Date
    Oct 2007
    Posts
    18
    Vote Rating
    2
    mcarsel is on a distinguished road

      0  

    Default


    OK, thanks. I had read the part about 'mapping' in the docs, but didn't grasp it until you explained it. Thanks for the advice.

    And to mjlecomte: The thread says it all. Read it carefully, especially the part about 'nested' objects and using the proper 'root'. I supplied a working example in my final code post and Animal provided another useful suggestion. Cobnet and JoeK provided useful info that got me further along. The previous examples were lacking just a bit in dealing with 'nested' objects in JSON. Looking back, I probably should have provided my code in the very first post.

  3. #23
    Ext User
    Join Date
    Jun 2007
    Posts
    98
    Vote Rating
    0
    ajaxE is on a distinguished road

      0  

    Default Didn't work in Firefox but worked in IE 6

    Didn't work in Firefox but worked in IE 6


    Quote Originally Posted by Animal View Post
    OK, You've done well so far, but it's not advisable to use dots in field names (and the therefor the ColumnModel dataIndex properties that reference them) because the dataIndex is used as a javascript property name, and dots are significant - there's another thread posted today where someone got bitten just just this: http://extjs.com/forum/showthread.php?t=17046

    What you need to do is define a mapping in field definition configs for the fields that are pulled from within an inner property.

    Code:
        var electronicDevice = Ext.data.Record.create([
           { name : 'id'},  // property name within the row object is the same as the field name
           { name : 'model', mapping: 'properties.model'}, // mapping needed here because name != mapping
           { name : 'deviceType', mapping: 'properties.deviceType'},
           { name : 'netBandWidth', mapping: 'properties.netBandwidth'}
        ]);
        
        var reader = new Ext.data.JsonReader({
     	   root : "features",
     	   totalProperty : "total",
     	   id : "id"
        }, electronicDevice);
        
        var store = new Ext.data.Store({
           nocache : true,
           reader : reader,
           autoLoad : true,
    	   remoteSort : true,
    	   proxy : new Ext.data.HttpProxy({
    	       url : '/getjson?queryable=featureType&featureType=Electronic%20Device',
    	       method : 'GET'
    	   })
    	});
    
        var grid1 = new xg.GridPanel({
            ds: store,
            cm: new xg.ColumnModel([
            {id : 'id', header : "Feature Number", width: 8, dataIndex : 'id'},
            {header: "Model", width: 10, dataIndex: 'model'},
            {header: "Device Type", width: 10, dataIndex: 'deviceType'},
            {header: "Net Bandwidth", width: 10, dataIndex: 'netBandwidth'}
    
            ...
    The documentation for Ext.data.record.create explains this.
    Hi Animal,

    Your example in reference nested json is very helpful. I tried your approach using mapping. It worked in IE 6 but not the latest Firefox. Firefox didn't give any error. It shows the blank grid. Any inside. I am using Ext2.0 grid.

    Thanks!

  4. #24
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Well you're in luck. Firefox has a good debugger. You can use ext-all-debug.js, and set a break in JsonReader.readRecords() and step through and find out exactly what is happening.

  5. #25
    Ext User
    Join Date
    Jun 2007
    Posts
    98
    Vote Rating
    0
    ajaxE is on a distinguished road

      0  

    Default


    Yes, I was lucky! Problem solved! Thanks Animal!

  6. #26
    Ext User
    Join Date
    Feb 2010
    Posts
    1
    Vote Rating
    0
    hottie1981 is on a distinguished road

      0  

    Default tryandls and animal

    tryandls and animal


    TryanDLS and Animal, why are you guys being so mean to him? He just wanted some help on a question, there's no need to be so terrible to him.

  7. #27
    Ext User
    Join Date
    Oct 2010
    Posts
    2
    Vote Rating
    2
    tatiananabokov is on a distinguished road

      2  

    Default


    God, this thread makes me sick. What better way to turn away new and potential developers than for a product's "Community Support Team" to belittle its newest community members. There is a time and place for RTFM, but save the heckling for community members who aren't paid staff or volunteers vested in the success of the framework.

    My initial impression of Ext and the Sencha Touch framework is that it is pretty good, but lacking in documentation (think proxy on jsonstore/jsonpstore) at times and a little too "beta" for us to purchase a commercial license... not to mention threads like these which, quite frankly, makes me want to avoid using Sencha forums to seek help with my Sencha-related questions.

  8. #28
    Sencha User conorarmstrong's Avatar
    Join Date
    Mar 2008
    Location
    Northern Ireland
    Posts
    224
    Vote Rating
    2
    conorarmstrong is on a distinguished road

      0  

    Default


    why are you not using the root you specified in the proxy?
    ------------------------------------------
    Conor Armstrong
    tw: @evathedog
    web: rockstown.com

    Ext.ux.form.AutoCombo
    Ext.ux.SimpleIFrame
    Ext.ux.form.ToolFieldSet

    Knowledge is realising that the street is one-way, wisdom is looking both directions anyway.

  9. #29
    Sencha User ben.tremblay's Avatar
    Join Date
    Apr 2007
    Location
    Edmonton, AB Canada
    Posts
    36
    Vote Rating
    0
    ben.tremblay is on a distinguished road

      0  

    Default


    Just for the record: I deleted a long reply because the original ... shall I call it "incident"? Anyhow, it was long ago.
    Just to say I was disappointed by the tone, and the indulgence.
    Water under the bridge; bigger fish to fry.
    If you look to see how the system works
    Likely you will find that it doesn't.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi