1. #1
    Sencha User tf.alves's Avatar
    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    54
    Answers
    3
    Vote Rating
    0
    tf.alves is on a distinguished road

      0  

    Default Answered: Store reading multiple roots

    Answered: Store reading multiple roots


    I have a JSON like the following:

    {"olditems":"true","items":[]}
    I assigned the reader of my store with the root 'items' because I want this items to populate my template. But I also want to read my olditems value, how can I do this?
    I have tried many things, but, if I set the root as "items" I can no longer have access to "olditems"

    All I need is to access this property in the listener 'load', so I can add an extra record to the store in case this property is set to true.

    Can anyone help me? I'm sure this one is quite easy to solve, but I've been googling around for the last couple of hours and this is driving me crazy!

  2. You can add this to the Store:

    Code:
    getOldItems: function() {
        var reader = this.proxy.reader;
    
        return reader.createAccessor('olditems')(reader.rawData);
    }
    reader.createAccessor creates a function that can look for the key you pass it, in this case you want to look for 'olditems'. You then execute that function passing in the raw data and the reader will then return that value.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,798
    Answers
    3467
    Vote Rating
    834
    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 can add this to the Store:

    Code:
    getOldItems: function() {
        var reader = this.proxy.reader;
    
        return reader.createAccessor('olditems')(reader.rawData);
    }
    reader.createAccessor creates a function that can look for the key you pass it, in this case you want to look for 'olditems'. You then execute that function passing in the raw data and the reader will then return that value.
    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.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    vinuthamsr is on a distinguished road

      0  

    Default JSON with 2 roots to be read

    JSON with 2 roots to be read


    Hi ,
    A small clarification. Is it possible to read such a structure to a extJs store ??
    Ur suggestion will be of great help.
    "results": [{
    "time",
    "values": [
    {
    "x":
    "y":
    },
    {
    "x":
    "y":
    },
    {
    "x":
    "y":
    }
    ]

    },
    {
    "time",
    "values": [
    {
    "x":
    "y":
    },
    {
    "x":
    "y":
    },
    {
    "x":
    "y":
    }
    ]
    }]

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