[Commits] r754 - sandbox/bartvde/legend/geoext/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Fri May 15 11:24:08 CEST 2009


Author: bartvde
Date: 2009-05-15 11:24:08 +0200 (Fri, 15 May 2009)
New Revision: 754

Modified:
   sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
Log:
update for layer visibility in legend

Modified: sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
===================================================================
--- sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js	2009-05-15 09:01:57 UTC (rev 753)
+++ sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js	2009-05-15 09:24:08 UTC (rev 754)
@@ -84,19 +84,41 @@
                 "add": this.onStoreAdd,
                 "move": this.onStoreMove,
                 "remove": this.onStoreRemove,
+                "update": this.onStoreUpdate,
                 scope: this
             });
         }
         this.doLayout();
     },
 
+    /** private: method[onStoreUpdate]
+     *  Update a layer within the legend panel. Gets called when the store
+     *  fires the update event. This usually means the visibility of the layer
+     *  has changed.
+     *
+     *  :param store: ``Ext.data.Store`` The store in which the record was
+     *      changed.
+     *  :param record: ``Ext.data.Record`` The record object corresponding
+     *      to the updated layer.
+     *  :param operation: ``String`` The type of operation.
+     */
+    onStoreUpdate: function(store, record, operation) {
+        var legend = this.getComponent(record.get('layer').id);
+        var layer = record.get('layer');
+        if (!layer.getVisibility()) {
+            legend.hide();
+        } else {
+            legend.show();
+        }
+    },
+
     /** private: method[onStoreMove]
      *  Relocate a layer within the legend panel. Gets called when the store
      *  fires the move event.
      *
      *  :param store: ``Ext.data.Store`` The store in which the record was
      *      moved.
-     *  :param record: ``Ext.data.Record`` The record object(s) corresponding
+     *  :param record: ``Ext.data.Record`` The record object corresponding
      *      to the moved layer.
      *  :param from: ``Integer`` The previous index of the moved record.
      *  :param to: ``Integer`` The new index of the moved record.



More information about the Commits mailing list