[Users] How to disable a Treenode ?
Robert Buckley
robertdbuckley at yahoo.com
Mon Nov 28 17:21:30 CET 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111128/2930bd7f/attachment.htm
More information about the Users
mailing list