sntial
1 Sep 2010, 7:51 PM
I have the following code which attempts to create a tree, but defer the load of data until a later point in time (basically I'll be frequently refreshing it as different items are opened up).
Ext.onReady(function() {
var oTreePanel = null;
oTreePanel = new Ext.tree.TreePanel({
id: "treePanel"
,renderTo: Ext.getBody()
,title: "Test tree"
,width: 300
,lines: false
,useArrows: true
,loader: new Ext.tree.TreeLoader()
,root: new Ext.tree.AsyncTreeNode({
id: "root"
,text: "Root"
})
,rootVisible: false
,listeners: {
click: function(n) {
if (!n.attributes.leaf) {
if (n.expanded) {
n.collapse();
} else {
n.expand();
}
return false;
}
Ext.Msg.alert('Navigation Tree Click', 'TODO xval: "' + n.attributes.xval + '"');
}
}
});
// defer the data load until a later point in time ... muliple refreshes
oTreePanel.enable();
oTreePanel.getLoader().dataUrl = "./tree.json";
oTreePanel.getLoader().baseParams = {applicationId: goUserInfo.applicationId};
oTreePanel.root.expand();
});
Example json pulled from an example:
[{
text: 'Grocery List',
cls: 'folder',
expanded: true,
children: [{
text: 'Bananas',
leaf: true
},{
text: 'Milk',
leaf: true
},{
text: 'Cereal',
leaf: true
},{
text: 'Energy foods',
cls: 'folder',
children: [{
text: 'Coffee',
leaf: true,
checked: false
},{
text: 'Red Bull',
leaf: true,
checked: false
}]
}]
}]
What happens is that when I set rootVisible = true everything works okay. When I set rootVisible = false nothing displays. I do not receive any JS error, just nothing gets rendered.
Is there some sort of bug, or is this the expected behavior. I'd like to hide the root node, because it makes no sense in the tree I'm trying to produce.
Ext.onReady(function() {
var oTreePanel = null;
oTreePanel = new Ext.tree.TreePanel({
id: "treePanel"
,renderTo: Ext.getBody()
,title: "Test tree"
,width: 300
,lines: false
,useArrows: true
,loader: new Ext.tree.TreeLoader()
,root: new Ext.tree.AsyncTreeNode({
id: "root"
,text: "Root"
})
,rootVisible: false
,listeners: {
click: function(n) {
if (!n.attributes.leaf) {
if (n.expanded) {
n.collapse();
} else {
n.expand();
}
return false;
}
Ext.Msg.alert('Navigation Tree Click', 'TODO xval: "' + n.attributes.xval + '"');
}
}
});
// defer the data load until a later point in time ... muliple refreshes
oTreePanel.enable();
oTreePanel.getLoader().dataUrl = "./tree.json";
oTreePanel.getLoader().baseParams = {applicationId: goUserInfo.applicationId};
oTreePanel.root.expand();
});
Example json pulled from an example:
[{
text: 'Grocery List',
cls: 'folder',
expanded: true,
children: [{
text: 'Bananas',
leaf: true
},{
text: 'Milk',
leaf: true
},{
text: 'Cereal',
leaf: true
},{
text: 'Energy foods',
cls: 'folder',
children: [{
text: 'Coffee',
leaf: true,
checked: false
},{
text: 'Red Bull',
leaf: true,
checked: false
}]
}]
}]
What happens is that when I set rootVisible = true everything works okay. When I set rootVisible = false nothing displays. I do not receive any JS error, just nothing gets rendered.
Is there some sort of bug, or is this the expected behavior. I'd like to hide the root node, because it makes no sense in the tree I'm trying to produce.