1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    172
    Answers
    7
    Vote Rating
    -10
    glafrance is infamous around these parts glafrance is infamous around these parts

      0  

    Default Unanswered: treestore not loading data

    Unanswered: treestore not loading data


    I have a popup window that has a treepanel that uses a tree store to load data. I had thought that because autoLoad is true, the treestore would load the data when the window and its treepanel are rendered, but no ajax call is being made.

    Code:
    {
        xtype: "treepanel",
        flex: 1,
        id: "switchCompanyGrid",
        margin: '0 7 0 7',
        store: {
            type: 'treestore',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: '/myservice/rest/api/ipass/300/svc/TTBB/Company/500'
            }
        },
        columns: [{
            xtype: 'treecolumn',
            text: 'Company Name',
            flex: 2,
            dataIndex: 'name'
        },{
            text: 'ID',
            flex: 1,
            dataIndex: 'id'
        },{
            text: 'Action',
            flex: 1
        }]
    }

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,984
    Answers
    662
    Vote Rating
    455
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Try loading your store first.

    Scott.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    172
    Answers
    7
    Vote Rating
    -10
    glafrance is infamous around these parts glafrance is infamous around these parts

      0  

    Default


    I'm somewhat new to ExtJS, so I'm not sure what you mean by try to load your store first.

    Do you mean that rather than having the store as a config in the tree panel I should create a var for the treestore so it gets loaded?

    But I'm still wondering, should my code in fact work as is? I thought that when autoLoad is true, then when the component is rendered the store loads. Is that not true?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,984
    Answers
    662
    Vote Rating
    455
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    The issue is that ajax takes time to return .. and your code has moved on..

    Scott.

  5. #5
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to fix your code like below. Also, you need to config fields or model for your store.
    Code:
    {
        xtype: "treepanel",
        flex: 1,
        id: "switchCompanyGrid",
        margin: '0 7 0 7',
        store: {
            // type: 'treestore', <- no need, TreePanel will automatically create Ext.data.TreeStore
            root: {}, // <- force treestore to setRootNode then it will load root data
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: '/myservice/rest/api/ipass/300/svc/TTBB/Company/500'
            }
        },
        columns: [{
            xtype: 'treecolumn',
            text: 'Company Name',
            flex: 2,
            dataIndex: 'name'
        },{
            text: 'ID',
            flex: 1,
            dataIndex: 'id'
        },{
            text: 'Action',
            flex: 1
        }]
    }

Thread Participants: 2