[Lada-commits] [PATCH 2 of 2] Update list on search and reset filter values on reset button click

Wald Commits scm-commit at wald.intevation.org
Fri Apr 17 15:16:28 CEST 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1429276644 -7200
# Node ID 2d482dfaa41a9fad406f43c4003cc29d4f964129
# Parent  a8389baaf4afa8b96eabd653ba916fe9ce9ff487
Update list on search and reset filter values on reset button click.

diff -r a8389baaf4af -r 2d482dfaa41a app/controller/Filter.js
--- a/app/controller/Filter.js	Fri Apr 17 15:16:50 2015 +0200
+++ b/app/controller/Filter.js	Fri Apr 17 15:17:24 2015 +0200
@@ -22,6 +22,8 @@
         'ProbenList'    // List of found Proben
     ],
 
+    displayFields: null,
+
     init: function() {
         this.control({
             // CSS like selector to select element in the viewport. See
@@ -52,25 +54,23 @@
      * selected search query
      */
     selectSql: function(element, record) {
-        var resultGrid = element.up('panel[name=main]').down('filterresultgrid');
         var filters = element.up('panel[name=main]').down('fieldset[name=filtervariables]');
         var columns = element.up('fieldset').down('displayfield[name=columns]');
         var desc = element.up('fieldset').down('displayfield[name=description]');
-        var displayFields = record[0].data.results;
+        this.displayFields = record[0].data.results;
         var filterFields = record[0].data.filters;
 
-        this.reset();
+        this.reset(element);
 
         var columnString = [];
-        for (var i = 0; i < displayFields.length; i++) {
-            columnString.push(displayFields[i].header);
+        for (var i = 0; i < this.displayFields.length; i++) {
+            columnString.push(this.displayFields[i].header);
         }
         columns.setValue(columnString.join(', '));
         desc.setValue(record[0].data.description);
 
         // Setup Columns of the probenlist
-        displayFields.reverse();
-        resultGrid.setupColumns(displayFields);
+        this.displayFields.reverse();
 
         // Setup Filters of the probenlist
         //
@@ -183,6 +183,7 @@
      */
     search: function(element) {
         var resultGrid = element.up('panel[name=main]').down('filterresultgrid');
+        resultGrid.setupColumns(this.displayFields);
         var filters = element.up('panel[name=main]').down('fieldset[name=filtervariables]');
         var search = element.up('fieldset').down('combobox[name=filter]');
 
@@ -202,15 +203,12 @@
         resultGrid.show();
     },
 
-    reset: function() {
-        // var buttons = Ext.getCmp('SearchBtnPanel');
-        // var result = Ext.getCmp('result');
-        // for (var i = 0; i < queries.length; ++i) {
-        //     var toHide = Ext.getCmp(queries[i]);
-        //     toHide.hide();
-        // }
-        // result.hide();
-        // buttons.hide();
+    reset: function(element) {
+        var filters = element.up('panel[name=main]').down('fieldset[name=filtervariables]');
+        for (var i = filters.items.length - 1; i >= 0; i--) {
+            var filter = filters.items.items[i];
+            filter.clearValue();
+        }
     },
 
     about: function() {


More information about the Lada-commits mailing list