View Full Version : How to set as root node in Ext.tree.TreePanel dynamically data with JSON type

6 Aug 2014, 12:43 AM
Hi, all!
I wanna do lazyLoading Tree and my server return the following json-data structure:

{"success": true, "results": [{"text" : "Audi", "id" : 100}, {"text": "BMW", "id": 101}]}

There is TreeLoader:

var treeLoader = new Ext.tree.TreeLoader({
url: GO.url('packets/packet/json'),
requestMethod: 'GET',
preloadChildren: true

And TreePanel:

var tree = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: false,
containerScroll: true,
rootVisible: false,
border: false,

loader: treeLoader,

root: {
nodeType: 'async',
text: 'Ext JS',
draggable: false,
id: 'src',
children: ??????

How to specify in the TreePanel that its rootNode is "results" element in json? :-/

8 Aug 2014, 3:24 AM
This is not possible on 3.x. You'll need to create your own JsonLoader implementation that has a custom processResponse method to read your custom JSON structure.

10 Aug 2014, 7:24 PM
I found a plagin: