View Full Version : static tree example

23 Apr 2009, 11:49 PM
Is there a tree example that uses static data? I see TreeLoader is used to turn JSON into TreeNodes, but is it possible to inline the JSON and get TreeNodes without hitting a URL?

For whatever reason the tree examples don't seem to work for me locally. I'm specifically interested in the column-tree example. The page loads and shows a grid, but no tree nodes are loaded. FireBug tells me my Apache is giving a 405 error, even though it looks to be configured to allow POSTs. IE also shows the grid with no nodes, but no errors. At any rate, for my purposes I don't need the data to come from a URL, I can hardcode it.

I could hardcode JavaScript to construct the node objects and set their properties, but I thought it should be possible to pass JSON to something like TreeLoader. Does TreeLoader only take a URL?

24 Apr 2009, 2:53 AM
Is there a tree example that uses static data

Yes, the Ext Docs. See the file {ext root}/docs/output/tree.js

24 Apr 2009, 9:42 AM
Aha. Very nice, thank you. For any others looking to do similar, you will find "Docs.classData" defined in tree.js, then it is used like this to specify the root node for the tree:

new Ext.tree.AsyncTreeNode({
text:'Ext JS',

24 Apr 2009, 12:15 PM
I have my tree working and I'm now moving to make it a ColumnTree. It works, but I have to specify uiProvider:Ext.tree.ColumnNodeUI or I can set uiProviders:{"c": Ext.tree.ColumnNodeUI} and use uiProvider:"c" for every tree node. Is there a way to avoid this redundancy for every node? I realize some trees won't want every node with the same uiProvider, but it seems convenient.

BTW, it seems the children property on the constructor config object for AsyncTreeNode is not documented. Maybe I can hook wherever the children property is used to create children nodes?