[Users] Layertreebuilder has issues when layer removed.
Phil Scadden
p.scadden at gns.cri.nz
Wed Jul 13 23:31:46 CEST 2011
It does turn out to be quite tricky I find. I tried filling in this code
with:
var gnode =
this.getNodeByText(this.getRootNode(),records.data.layer.group);
if (gnode && gnode.childNodes.length == 1) {
gnode.remove();
}
which was too simple minded. onLayerremoved is called BEFORE the layer
is actually removed (hence
the length==1) and node removal then creates oddness by which layers are
not then actually removed.
It would seem to work better if node was marked for delete but then I
couldnt find an event to do the actual clean up.
In meantime I have "almost works" code in my main code of:
for (var i = 0; i<tree.getRootNode().childNodes.length; i++) {
if (tree.getRootNode().childNodes[i].childNodes.length==0) {
tree.getRootNode().childNodes[i].remove();
}
}
but this only works if I have only one level of grouping. If you can
give me any pointers as to a better way to proceed, I am very willing to
try them out.
--
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St,
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232
Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
More information about the Users
mailing list