node.getUI().checkbox.nextElementSibling.setValue(1);<br><br>could probably be replaced by <br><br>Ext.get(node.attributes.radio).setValue(1);<br><br>Other than that, your solution is fine.<br><br><div class="gmail_quote">
On Fri, Dec 10, 2010 at 3:04 PM, 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;">
Nice! Thanks a lot for your answer.<br>
<br>
I was also able to accomplish the same with this hack:<br>
<br>
function setLayerRadioButton(layerID) {<br>
selNodes = treePanel.getChecked();<br>
Ext.each(selNodes, function(node){<br>
if (<a href="http://node.layer.id" target="_blank">node.layer.id</a> == layerID) {<br>
node.getUI().checkbox.nextElementSibling.setValue(1);<br>
// trigger the 'radiochange' event manually here...<br>
}<br>
});<br>
<br>
};<br>
<br>
Regards,<br>
David<br>
<br>
2010/12/10 Pierre Giraud <<a href="mailto:pierre.giraud@camptocamp.com">pierre.giraud@camptocamp.com</a>>:<br>
<div><div></div><div class="h5">> 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<br>
> execute the 'set active layer' code on your own at the same time.<br>
><br>
> Please also consider using the new "GeoExt.plugins.TreeNodeRadioButton"<br>
> instead of the mixin. You may need a recent version of GeoExt though.<br>
><br>
> Regards,<br>
> Pierre<br>
><br>
> On Thu, Dec 9, 2010 at 10:39 AM, David E. Reksten <<a href="mailto:der@dod.no">der@dod.no</a>> wrote:<br>
>><br>
>> 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<br>
>> 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>
><br>
><br>
><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" target="_blank">http://www.camptocamp.com</a><br>
><br>
</div></div></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>