Hi,<br><br>I've just tried and I've succeeded in using the following piece of code :<br><br>var node = treePanel.root.findChild('layer', newVectorLayer, true);<br>Ext.get(node.attributes.radio).set({<br> 'checked': 'checked'<br>
});<br><br>This won't fire the 'radiochange' event though. However, I think you can execute the 'set active layer' code on your own at the same time.<br><br>Please also consider using the new "GeoExt.plugins.TreeNodeRadioButton" instead of the mixin. You may need a recent version of GeoExt though.<br>
<br>Regards,<br>Pierre<br><br><div class="gmail_quote">On Thu, Dec 9, 2010 at 10:39 AM, David E. Reksten <span dir="ltr"><<a href="mailto:der@dod.no">der@dod.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I have layer tree in my application with both checkboxes (visibility)<br>
and radiobuttons ("active layer").<br>
<br>
Users may add new vector layers via a button, but for the moment they<br>
must always manually click the radio button after adding the layer to<br>
activate it. I would have preferred that a new layer was automatically<br>
checked, but I am unable to find out how to do it. Ideally, I would<br>
like to set the radio button at the same time as after having added<br>
the new layer to the map. I have googled extensively, but I suspect<br>
that I am using the wrong terminology here, as I have been unable to<br>
find out how to achieve this. Any hints would be very much<br>
appreciated!<br>
<br>
My tree panel is defined like this:<br>
<br>
treeConfig = [{<br>
nodeType: "gx_baselayercontainer",<br>
text: "Base layers",<br>
expanded: true<br>
}, {<br>
nodeType: "gx_overlaylayercontainer",<br>
text: "My overlays",<br>
expanded: true,<br>
loader: {<br>
baseAttrs: {<br>
radioGroup: "foo",<br>
uiProvider: "use_radio"<br>
}<br>
}<br>
}];<br>
<br>
treePanel = new Ext.tree.TreePanel({<br>
id: 'mainpanel',<br>
border: true,<br>
region: "west",<br>
title: "My layers",<br>
width: 200,<br>
split: true,<br>
collapsible: true,<br>
margins: '0 0 5 5',<br>
collapseMode: "mini",<br>
autoScroll: true,<br>
loader: new Ext.tree.TreeLoader({<br>
// applyLoader has to be set to false to not interfere with loaders<br>
// of nodes further down the tree hierarchy<br>
applyLoader: false,<br>
uiProviders: {<br>
"use_radio": Ext.extend(GeoExt.tree.LayerNodeUI, new<br>
GeoExt.tree.RadioButtonMixin());<br>
}<br>
}),<br>
root: {<br>
nodeType: "async",<br>
children: treeConfig<br>
},<br>
listeners: {<br>
"radiochange": function(node){<br>
// toggle active layer<br>
}<br>
},<br>
rootVisible: false,<br>
lines: false<br>
});<br>
<br>
After the user has clicked the button to add a layer:<br>
// ... newVectorLayer is defined here ...<br>
map.addLayer(newVectorLayer);<br>
// would now like to activate the radio button in the TreePanel<br>
for "newVectorLayer", so that the "radiochange" event is triggered:<br>
but how?<br>
<br>
<br>
Regards,<br>
David<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Pierre GIRAUD<br>Géomaticien, Analyste<br><br>Camptocamp France SAS<br>Savoie Technolac, BP 352<br>73377 Le Bourget du Lac, Cedex <br><br>Tel : 00 33 4 79 44 44 93<br>Mail : <a href="mailto:pierre.giraud@camptocamp.com">pierre.giraud@camptocamp.com</a><br>
<a href="http://www.camptocamp.com">http://www.camptocamp.com</a> <br>