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

commits at geoext.org commits at geoext.org
Thu May 14 19:12:06 CEST 2009


Author: bartvde
Date: 2009-05-14 19:12:06 +0200 (Thu, 14 May 2009)
New Revision: 730

Modified:
   sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
Log:
basic add and remove layer functionality for legend panel

Modified: sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
===================================================================
--- sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js	2009-05-14 17:07:35 UTC (rev 729)
+++ sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js	2009-05-14 17:12:06 UTC (rev 730)
@@ -73,25 +73,41 @@
 
     /** private: method[onStoreAdd]
      *  Private method called when a layer is added to the store.
+     *
+     *  :param store: ``Ext.data.Store`` The store to which the record(s) was 
+     *      added.
+     *  :param record: ``Ext.data.Record`` The record object(s) corresponding
+     *      to the added layers.
+     *  :param index: ``Integer`` The index of the inserted record.
      */
-    onStoreAdd: function() {
+    onStoreAdd: function(store, records, index) {
+        for (var i=0, len=records.length; i<len; i++) {
+            this.addLegend(records[i]);
+        }
+        this.doLayout();
     },
 
     /** private: method[onStoreRemove]
      *  Private method called when a layer is removed from the store.
+     *
+     *  :param store: ``Ext.data.Store`` The store from which the record(s) was
+     *      removed.
+     *  :param record: ``Ext.data.Record`` The record object(s) corresponding
+     *      to the removed layers.
+     *  :param index: ``Integer`` The index of the removed record.
      */
-    onStoreRemove: function() {
+    onStoreRemove: function(store, record, index) {
+        this.removeLegend(record);
     },
 
-    /** private: method[onDestroy]
-     *  Private method called during the destroy sequence.
+    /** private: method[removeLegend]
+     *  Remove the legend of a layer.
+     *  :param record: ``Ext.data.Record`` The record object from the layer 
+     *      store to remove.
      */
-    onDestroy: function() {
-        if(this.layerStore) {
-            this.layerStore.un("add", this.onStoreAdd, this);
-            this.layerStore.un("remove", this.onStoreRemove, this);
-        }
-        GeoExt.LegendPanel.superclass.onDestroy.apply(this, arguments);
+    removeLegend: function(record) {
+        this.getComponent(record.get('layer').id).hide();
+        this.doLayout();
     },
 
     /** private: method[addLegend]
@@ -151,7 +167,19 @@
         };
         var panel = new Ext.Panel(panelConfig);
         return panel;
+    },
+
+    /** private: method[onDestroy]
+     *  Private method called during the destroy sequence.
+     */
+    onDestroy: function() {
+        if(this.layerStore) {
+            this.layerStore.un("add", this.onStoreAdd, this);
+            this.layerStore.un("remove", this.onStoreRemove, this);
+        }
+        GeoExt.LegendPanel.superclass.onDestroy.apply(this, arguments);
     }
+    
 });
 
 Ext.reg('gx_legend', GeoExt.LegendPanel);



More information about the Commits mailing list