Results 1 to 5 of 5

Thread: treestore not loading data

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    172
    Answers
    7

    Default 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
    9,409
    Answers
    716

    Default

    Try loading your store first.

    Scott.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    172
    Answers
    7

    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
    9,409
    Answers
    716

    Default

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

    Scott.

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347

    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
        }]
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •