1. #1
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    38
    Vote Rating
    0
    andrea.chiozzi@metislab.net is on a distinguished road

      0  

    Default Unanswered: JSON STORE PROBLEM: Sencha doesn't call json decode on my data

    Unanswered: JSON STORE PROBLEM: Sencha doesn't call json decode on my data


    Good day folks,
    I've a problem with JSONSTORE.. I'll write my code, and then I'll tell you where the problem is:

    Code:
            Ext.define('newModel', {
                extend: 'Ext.data.Model',
                fields: [{
                    name: 'idn',
                    type: 'int'
                }, {
                    name: 'text',
                    type: 'string'
                }, {
                    name: 'dsc',
                    type: 'string'
                }]
            });        
                    
            var tabpanel = Ext.create('Ext.tab.Panel', {
                tabBar: {
                    docked: 'bottom',
                    layout: { pack: 'center' }
                },
                fullscreen: true,
                defaults: {
                    scrollable: true
                },
                items: [{
                        xtype: 'list',
                        title: 'Zoom',
                        iconCls: 'bookmarks',
    
                        itemTpl: '{title}',  
                        itemTpl: '<div>{idn} - {text} - {dsc}</div>',
                        store: {
                            model: 'newModel',
                            proxy: {
                                type: 'ajax',   
                                api: {
                                    create:  undefined,
                                    read:    this.AJAX_REQUEST_URL   
                                    update:  undefined,   
                                    destroy: undefined   
                                },
                                reader: {    
                                    type: 'json',
                                    root: 'mResponseData.rows.results',
                                    successProperty: 'bRequestResult',
                                    totalProperty: 'mResponseData.totalCount'        
                                }                          
                            },                         
                            autoLoad: true
                        }                
                }]
            });
    My response is well formatted, so after that some sencha functions are called I get:

    successProperty => myResponse.bRequestResult ( PERFECT! )
    totalProperty =>myResponse.mResponseData.totalCount ( PERFECT! )
    root =>myResponse.mResponseData.rows.results ( PROBLEM! )

    The problem is that root value is a JSON string
    Code:
    "[{"idn":1,"text":"text1","dsc":"aaa"},{"idn":2,"text":"text2","dsc":"bbb"}{"idn":3,"text":"text3","dsc":"ccc"}]"
    and Sencha doesn't call a json decode on it...
    so ... sencha use the string as array, and I get a store with 116 records ( one for each char ) without info, because sencha doesn't discovery fields like idn, mane and dsc...

    If I change the code and add the command:
    root = Ext.JSON.decode( root )

    all works fine....

    can help me to find the problem.

    Thanks so much!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    All JsonStore does is setup a proxy and a json reader. The only time json reader will read JSON is if you are remotely loading data. If you are using add or insert or loadRecords, you have to pass in JavaScript or Ext.data.Model instances.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    38
    Vote Rating
    0
    andrea.chiozzi@metislab.net is on a distinguished road

      0  

    Default I don't understand x (

    I don't understand x (


    Hi Mitchell,
    and thanks for your aids...

    I've read your message, but I doesn't understand it very well : (

    I load remote data ( from this.AJAX_REQUEST_URL ) ...
    and Sencha uses very well the reader information ( root, successproperty, ecc ecc )
    but it doesn't call json decode ( because I missing something )

    so.. server give me that data:
    {"bRequestResult":true,"mResponseData":{"rows":{"results":"[{\"idn\":1,\"text\":\"text1\",\"dsc\":\"aaa\"},{"results":"[{\"idn\":2,\"text\":\"text2\",\"dsc\":\"bbb\"},.]"},"totalCount":3}}
    Sencha decode in this:
    Code:
    bRequestResult: true
    mResponseData: Object
        rows: Object
            results:"[{"idn":1,"text":"text1","dsc":"aaa"},{"idn":2,"text":"text2","dsc":"bbb"}, ecc ecc]"
        totalCount: 3
    and that is good... if only results was
    Ext.JSON.decode( "[{"idn":1,"text":"text1","dsc":"aaa"},{"idn":2,"text":"text2","dsc":"bbb"}
    {"idn":3,"text":"text3","dsc":"ccc"}]")

    the world will be more beautiful : )
    Maybe the answear is in your previous post.. can repeat it in simplest mode? : )

    Thanks again!!

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You need to set a root and successProperty on the reader to map to the correct level in your JSON
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    38
    Vote Rating
    0
    andrea.chiozzi@metislab.net is on a distinguished road

      0  

    Default


    You need to set a root and successProperty on the reader to map to the correct level in your JSON
    But I've done it...
    and it works ( without reader sencha doesn't read data in mResponseData.rows.results )
    but result value is get as string and not decoded in array ...
    I dont't know because it happenes ( is my first time with sencha touch) but is like if the params
    type: 'json' was not used... o_O
    Code:
                        store: {
                            model: 'newModel',
                            proxy: {
                                type: 'ajax',   
                                api: {
                                    create:  undefined,
                                    read:    this.AJAX_REQUEST_URL   
                                    update:  undefined,   
                                    destroy: undefined   
                                },
                                reader: {    
                                    type: 'json',
                                    root: 'mResponseData.rows.results',
                                    successProperty: 'bRequestResult',
                                    totalProperty: 'mResponseData.totalCount'        
                                }                          
                            },                         
                            autoLoad: true
                        }

  6. #6
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    The data package has had a major refactor since PR3, and it will be available in the next release. I'd wait for that release and see if it works then. If not, submit a bug report.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  7. #7
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    38
    Vote Rating
    0
    andrea.chiozzi@metislab.net is on a distinguished road

      0  

    Default


    Ok rdougan,
    thanks for the info!!

Thread Participants: 2

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