View Full Version : Tree: how to load the root node and other root node issues

5 Dec 2011, 6:41 PM

Here is my code:

Ext.define('Menu', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
proxy: {
type: 'rest',
url : '/rest/menu',
reader: {
type: 'json',
root: 'data'

The store I'm using:

store = Ext.create('Ext.data.TreeStore', {
model: 'Menu',
nodeParam: 'id'

But it doesn't load anything (I checked the requests made by the browser: 0 for the targeted URL).
So I force the load with a store.load(); ... but then, it requests 2 times the URL and so creates 2 children for the root node.

So two problems:

the nodes are append to the root node. I want the fetched data to be the root node.
the double request
Here is the JSON:


In addition, this node has children but they are not requested with the previous code. However, if I force the root node in the store with:

root: { id:1, name:'Home' }
Then all the problems disappear and I can dynamically load child node, children of child nodes, etc.

... :s

6 Dec 2011, 1:53 PM
You should specify the root node. You can hide the root via the rootVisible config on the Ext.tree.Panel.