[Users] How to disable a Treenode ?
Andreas Hocevar
ahocevar at opengeo.org
Mon Nov 28 17:43:14 CET 2011
You are confusing layer (i.e. instances of OpenLayers.Layer, which
have a setVisibility() method) and node (i.e. instances of
Ext.tree.TreeNode, which have a config option "disabled", which only
controls the initial enabled/disabled state upon instance creation,
and enable() and disable() methods). As you found out, you are using
setVisibility in the correct context (the layer), but you are totally
off controlling the node.
Search the archives, this question was thoroughly answered a few weeks
ago. IIRC even a code snippet was provided.
Andreas.
On Mon, Nov 28, 2011 at 5:21 PM, Robert Buckley
<robertdbuckley at yahoo.com> wrote:
> Hi,
> I want to disable treenode like in this webapp (http://www2.visdat.de/) look
> at "Freie Webdienste" which nicely disables treenodes after a certain
> resolution.
> The relevant code is this....
> "
> map.events.register('zoomend', map, function (e) {
> if (map.getZoom() < minZoom) {
> map.zoomTo(minZoom)
> };
> if (map.getZoom() > maxZoom) {
> map.zoomTo(maxZoom)
> };
>
> for (var k = 0; k < layerArray.length; k++) {
> var layerId = layerArray[k][8];
> if (layerTree.getNodeById(layerId)) {
> if ((map.getResolution() >= layerArray[k][9] &&
> map.getResolution() <= layerArray[k][10]) || (layerArray[k][9] == null &&
> layerArray[k][10] == null)) {
> layerTree.getNodeById(layerId).enable();
> }
> if (layerArray[k][9] != null && layerArray[k][10] !=
> null) {
> if (map.getResolution() <= layerArray[k][9] ||
> map.getResolution() >= layerArray[k][10]) {
> layerTree.getNodeById(layerId).disable();
> }
> }
> };
> }
>
>
> "
> In my Application I wanted to disable a treenode when the zoomlevel goes
> above 12, but although api docs (http://www.myext.cn/ext-3.2.1/docs/) say
> that a treenode has a disabled property, firebug says otherwise
> According to the geoext docs
> (http://geoext.org/lib/GeoExt/widgets/tree/LayerNode.html)
> "Configuration properties in addition to those listed
> for Ext.tree.TreeNode."
>
> So I looked at the Ext.tree.TreeNod propertie and saw this...
> disabled : Boolean
> true to start the node disabled
> So, I tried this...
> map.events.on({
> "zoomend": function (e) {
> if (this.getZoom() > 12) {
>
> layer_1.setVisibility(true);
> layer_1.disabled="false";
>
>
> } else {
> layer_1.setVisibility(false);
> layer_1.disabled="true";
>
> var mapcenter = getMapCenter();
>
> }
> }
> });
> and my console reports "has no method 'disable'"
> The setVisibility(true); works ok, but this method isn´t even documented!
> I am not a javaascript guru unfortunately, but I thought I could understand
> the docs...now i´m not too sure.
> Thanks for any help,
> Rob
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list