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.

_______________________________________________
Users mailing list
Users@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to