PDA

View Full Version : Tree using TreeStore and proxy not working



johnterran
30 Dec 2011, 10:26 AM
Hi,


I am trying to build a tree using TreeStore with proxy, but it is not working for me.

Ext.define('MyTreeStore', {
extend: 'Ext.data.TreeStore',
storeId: 'MyTreeStore',
root: {
expanded: true,
proxy: {
reader: 'json',
url: 'treedata.js'
}
}
});


// treedata.js
{
"children": [
{text: "A"},
{text: "B"},
{text: "C"}
]
}
What am I doing wrong?

Thanks
John

mitchellsimoens
30 Dec 2011, 11:05 AM
What isn't working? Please wrap your code in code tags.

johnterran
30 Dec 2011, 11:22 AM
Nothing shows up on the tree.
I was expecting nodes "A", "B", "C"

Is my json format correct? Do I need to autoLoad the treestore?

mitchellsimoens
30 Dec 2011, 11:26 AM
The treestore should load when a node is expanded. Did you check to see if a request is made?

johnterran
30 Dec 2011, 1:11 PM
I didn't see the request for the treedata.js. I don't see any nodes on the tree to expand.

Why isn't my proxy fetching the treedata.js?

Do you have an example where the proxy is fetching a json object from a js file?

ero
12 Jan 2012, 9:35 AM
Have you tried working with any of the examples?

From a glance, it doesn't look like you've configured the store properly - I don't see any reference to a model or to fields in your code.