1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    São Paulo - SP
    Posts
    22
    Vote Rating
    0
    maps_tecnologia is on a distinguished road

      0  

    Default Answered: Load treestore with inline html json.

    Answered: Load treestore with inline html json.


    Hi, I am making a tree.Panel that in the future will have information suplied to it by a rest url.

    Before implementing that, I am rendering a js html tag that contains my json.

    The problem I am facing involves lodaing that data into my tree store.

    I have a proxy defined that reads a 'dummy' url where I put a test json, but I cant find a way to define a proxy to read inline data.
    Store
    Code:
    var store = Ext.create('Ext.data.TreeStore', {		fields: [
    		         {name: 'values', type: 'object'}
    		],
            proxy: {
                type: 'ajax',
                url: './dummyOutput.js',
                reader: {
                	type: 'json',
                	root: 'children'
                }
            }
    });
    Dummy json
    Code:
    {
        "children": [
            {
                "values": {
    	            "class": "a",
    		        "name": "Joe"
    	        },
                "children": [
                    {
                        "values": {
                        	"class": "a",
                            "name": "Bob"
                        },
                        "leaf": true,
                        "children": []
                    },
                    {
                    	"values": {
    	                    "class": "a",
    	                    "name": "Fran"
                        },
                        "leaf": true,
                        "children": []
                    }
                ]
            },
            {
                "values": {
                	"class": "b",
                	"name": "Lilian"
                },
                "leaf": true,
                "children": []
            }
        ]
    }
    Json I created programatically
    Code:
    {
        "children": [
            {
                "children": [
                    {
                        "children": null,
                        "values": {
                            "abc": 123,
                            "def": 444
                        }
                    }
                ],
                "values": {
                            "abc": 332,
                            "def": 666
                }
            }
        ]
    }
    I read the inline json and decode it as follows:

    Code:
    var data = Ext.decode(Ext.get('output.js').dom.innerHTML);
    Doing
    Code:
    store.load(data);
    doesnt seem to work. The problem is figuring out a proxy for this situation.

    Thanks for the time.

  2. In the case of the TreeStore you need to add the children to the root node

  3. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    During testing, you can comment out your proxy and use the data attribute of the Store to house your JSON.

  4. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    In the case of the TreeStore you need to add the children to the root node
    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. #4
    Sencha User
    Join Date
    Oct 2011
    Location
    São Paulo - SP
    Posts
    22
    Vote Rating
    0
    maps_tecnologia is on a distinguished road

      0  

    Default


    Code:
            
    root: {
          children: data
    }
    That did it. =D

    Thanks.

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