-
14 Sep 2012 9:47 AM #1
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 }] }
-
14 Sep 2012 10:16 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,183
- Vote Rating
- 194
- Answers
- 433
Try loading your store first.
Scott.
-
14 Sep 2012 10:23 AM #3
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?
-
14 Sep 2012 10:55 AM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,183
- Vote Rating
- 194
- Answers
- 433
The issue is that ajax takes time to return .. and your code has moved on..
Scott.
-
14 Sep 2012 3:44 PM #5
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 }] }


Reply With Quote