View Full Version : Need to update TreeNode config while loading JSON data for a tree using TreeLoader

14 Oct 2009, 5:15 AM

I am using a TreeLoader to load data for a TreePanel.

App.custom.Tree = Ext.extend(Ext.tree.TreePanel, {
renderTo: 'tree-div',
loader: new Ext.tree.TreeLoader({
title: 'My TreePanel'

The data from server would look like
[{id: 11,text: 'A leaf Node1',leaf: true}]

Currently the data sent by the server, sets id,text and leaf of a TreeNode.
Now what I want is to configure extra details for each Node.
For example I would want to enable checkboxes for all nodes.

Can I do this without changing the data sent from the server?

I tried extending "Ext.tree.TreeNodeUI" and setting it for "uiProviders" of TreeLoader.
May be I didnt do it right.

Is there a way to achieve this by using baseParams of TreeLoader?

14 Oct 2009, 6:08 AM
baseParams is meant for sending default parameters to the server-side. This doesn't sound quite like what you want.

Take a look at the baseAttrs configuration. This allows you to set base attributes for each node without sending them back from the server-side. If you want to perform any custom logic combining/creating attributes you will have to override a method like createNode. If you want to create a custom UI you should probably extend TreeNodeUI and use uiProviders.

14 Oct 2009, 6:30 AM
Yes. Thats exactly what I did(override a method like createNode). And it worked. Thanks anyways.

tree.setRootNode(new Ext.tree.AsyncTreeNode({
loader: new Ext.tree.TreeLoader({
createNode: function(attr) {
if(enableCheckBox == 'true') {
attr.checked = false;
return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);

I will check out "baseAttrs configuration".