PDA

View Full Version : Can't re-add a previously removed TreeNode to my TreePanel



Planet_x
9 Nov 2010, 3:11 PM
I am trying to add a previously removed treenode (with the layerRoot_Legend.removeAll() method) but when I add it back by using .appendChild(name of node) it does not appear. Is there any way to re-add the node without destroying it as I am guessing it is being completely destroyed since I am able to add different nodes just not ones I have used the remove/removeAll method on. Below is my code appreciate any help on how I can first remove the layerList_Labels node properly then re-add it.



var layerRoot_Legend = new Ext.tree.TreeNode({
enableDD: true,
text: "All Legend Items",
expanded: true
});

var layerTree_Legend = new Ext.tree.TreePanel({
title: '',
root: layerRoot_Legend,
enableDD: true,
applyLoader: true,
rootVisible: false
});


//Labels LayerList
layerList_Labels = new GeoExt.tree.LayerContainer({
text: 'Labels',
layerStore: mapPanel.layers,
leaf: false,
cls: 'rootnode',
enableDD: true,
singleClickExpand: true,
expanded: false,
checked: false,
listeners: {
'checkchange' : function(node, checked)
{
// If a parent node is unchecked, uncheck all the children
if (node.getUI().isChecked()) {
node.expand();
node.eachChild(function(child){
child.ui.toggleCheck(true);
});
}
if (!node.getUI().isChecked())
{
node.expand();
node.eachChild(function(child) {
child.ui.toggleCheck(false);
});
}
}
},
loader:
{
filter: function(record)
{
var myarr = new Array();
myarr[0] = record.get("layer").name.indexOf("Neighbourhood Label");
myarr[1] = record.get("layer").name.indexOf("Overview Streets");
myarr[2] = record.get("layer").name.indexOf("Quadrant Streets");
myarr[3] = record.get("layer").name.indexOf("Neighbourhood Streets");
myarr[4] = record.get("layer").name.indexOf("Block Streets");
myarr[5] = record.get("layer").name.indexOf("Proposed Streets");
myarr[6] = record.get("layer").name.indexOf("Address Label (Overview)");
myarr[7] = record.get("layer").name.indexOf("Address Label (Detail)");
if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1 && myarr[3]==-1 && myarr[4]==-1 && myarr[5]==-1 && myarr[6]==-1 && myarr[7]==-1)
{
returnfalse;
}
else
{
returntrue;
}
}
}
});

layerRoot_Legend.appendChild(layerList_Labels);

layerRoot_Legend.removeAll();

layerRoot_Legend.appendChild(layerList_AssessedIncrements);
layerRoot_Legend.appendChild(layerList_Labels);



So the previously added layerList_Labels node does not get added because it was already on the treenode, but the AssessedIncrements is added fine, how can I add both? Thanks.

Planet_x
9 Nov 2010, 3:19 PM
nevermind I looked at previous bug reports from the forum and I just added -
layerRoot_Legend.beginUpdate() and then
layerRoot_Legend.endUpdate() and it worked.