[Users] How to disable a Treenode ?
Robert Buckley
robertdbuckley at yahoo.com
Mon Nov 28 19:39:24 CET 2011
HI,
Thanks a million Andreas!
I´ve been tearing my hair out for months on and off for the following EASY solution.......
map.events.on({
"zoomend": function (e) {
if (this.getZoom() > 12) {
layer_Flurbloeke.setVisibility(true);
layerTree.getRootNode().findChild('layer', layer_1, true).enable();
} else {
layer_1.setVisibility(false);
layerTree.getRootNode().findChild('layer', layer_1, true).disable();
}
}
});
This checks/unchecks the layer and disables the treenode on the required zoom level!!!
Yours,
Rob
________________________________
Von: Andreas Hocevar <ahocevar at opengeo.org>
An: Robert Buckley <robertdbuckley at yahoo.com>
Cc: "users at geoext.org" <users at geoext.org>
Gesendet: 17:43 Montag, 28.November 2011
Betreff: Re: [Users] How to disable a Treenode ?
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111128/35acd81d/attachment-0001.htm
More information about the Users
mailing list