[icinga-checkins] icinga.org: icinga-web/mhein/reporting: * Added fix for filters in grid

git at icinga.org git at icinga.org
Wed Jul 13 15:01:11 CEST 2011


Module: icinga-web
Branch: mhein/reporting
Commit: fcfffda7c00b875cea9f0c0fff2c290f42cd879d
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=fcfffda7c00b875cea9f0c0fff2c290f42cd879d

Author: Marius Hein <marius.hein at netways.de>
Date:   Wed Jul 13 14:59:20 2011 +0200

* Added fix for filters in grid

---

 app/modules/Cronks/lib/js/grid/GridPanel.js        |    8 +++--
 .../System/ViewProc/AjaxGridLayoutSuccess.php      |    3 +-
 .../System/ViewProc/js/IcingaGridFilterHandler.js  |   32 ++++++++++++-------
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/app/modules/Cronks/lib/js/grid/GridPanel.js b/app/modules/Cronks/lib/js/grid/GridPanel.js
index 19cf5af..10d4107 100755
--- a/app/modules/Cronks/lib/js/grid/GridPanel.js
+++ b/app/modules/Cronks/lib/js/grid/GridPanel.js
@@ -26,9 +26,11 @@ Cronk.grid.GridPanel = Ext.extend(Ext.grid.GridPanel, {
 			});
 		}			
 		Cronk.grid.GridPanel.superclass.initComponent.call(this);
+		
 		this.on("show",function() {
-			if(this.autoRefreshEnabled)
+			if(this.autoRefreshEnabled) {
 				this.startRefreshTimer();
+			}
 		},this);
 	
 	},
@@ -46,7 +48,7 @@ Cronk.grid.GridPanel = Ext.extend(Ext.grid.GridPanel, {
 				text: _('Refresh'),
 				iconCls: 'icinga-icon-arrow-refresh',
 				tooltip: _('Refresh the data in the grid'),
-				handler: function(oBtn, e) { this.store.reload(); },
+				handler: function(oBtn, e) { this.store.load(); },
 				scope: this
 			}, {
 				text: _('Settings'),
@@ -256,6 +258,7 @@ Cronk.grid.GridPanel = Ext.extend(Ext.grid.GridPanel, {
 			aR = 1;
 		if(this.autoRefreshEnabled === false)
 			aR = -1;
+		
 		var o = {
 			filter_params: this.filter_params || {},
 			filter_types: this.filter_types || {},
@@ -298,7 +301,6 @@ Cronk.grid.GridPanel = Ext.extend(Ext.grid.GridPanel, {
 		}
 
 		if (reload == true) {
-			
 			this.refreshGrid();
 		}
 					
diff --git a/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php b/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
index c5301b8..2f751c0 100755
--- a/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
+++ b/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
@@ -18,10 +18,11 @@ Cronk.util.initEnvironment(<?php CronksRequestUtil::echoJsonString($rd); ?>, fun
 		
 		MetaGrid.setStoreUrl("<?php echo $ro->gen('cronks.viewProc.json', array('template' => $rd->getParameter('template'))); ?>");
 		MetaGrid.setParameters(<?php echo json_encode($rd->getParameters()); ?>);
-
 		MetaGrid.setParameters({storeDisableAutoload: true});
+		
 		var grid = MetaGrid.createGrid();
 		CE.setStatefulObject(grid);
+		
 		// Add the window to a toolbar button
 		grid.on('render', function(g) {
 			
diff --git a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
index 7e40ab9..d32ed4e 100755
--- a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
+++ b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
@@ -287,17 +287,21 @@ Cronk.util.GridFilterWindow = function() {
 			 */
 			setGrid : function(g) {
 				oGrid = g;
+				
 				if ("originParams" in oGrid.getStore()) {
 					oOrgBaseParams = oGrid.getStore().originParams;
 				}
 				
 				oGrid.on('activate', function() {
-	
 					if (oCoPanel) {
 						oGrid.filter_params = getFormValues(false);
 					}
 					return true;
-				});
+				}, this);
+				
+				oGrid.getStore().on('datachanged', function(store) {
+					this.markActiveFilters();
+				}, this);
 				
 				if (oGrid.filter_params) {
 					oGrid.on("render",this.applyFilters.createDelegate(this,oGrid.filter_params));
@@ -325,15 +329,18 @@ Cronk.util.GridFilterWindow = function() {
 				oFilter = {}; 
 			},
 
-			markActiveFilters : function(data) {
+			markActiveFilters : function() {
 				var btn = Ext.getCmp(oGrid.id+"_filterBtn");
 				if(!btn) {
 					this.markActiveFilters.defer(200,this,[data]);
 					return true;
 				}
+				
 				var i = 0;
-				for(var elem in data)
+				for (var ele in oGrid.filter_params) {
 					i++;
+				}
+			
 				if(i)
 					btn.addClass("activeFilter");
 				else
@@ -346,17 +353,13 @@ Cronk.util.GridFilterWindow = function() {
 			 */
 			applyFilters : function(owd) {
 				var data = owd || getFormValues();
-				this.markActiveFilters(data);
 				oGrid.getStore().baseParams = {};
 				Ext.apply(oGrid.getStore().baseParams, oOrgBaseParams);
 				Ext.apply(oGrid.getStore().baseParams, data);
-	//			console.log(data);
-	//			console.log('APPLY');
-	//			console.log(oGrid.getStore().baseParams);
 			
 				
-				oGrid.getStore().reload();
-				// oGrid.fireEvent('activate');
+				oGrid.getStore().load();
+				oGrid.fireEvent('activate');
 				
 				oWindow().hide();
 			},
@@ -369,10 +372,15 @@ Cronk.util.GridFilterWindow = function() {
 				oGrid.getStore().baseParams = oOrgBaseParams;
 				oGrid.filter_params = null;
 				oGrid.filter_types = null;
-				oGrid.getStore().reload();
+				oGrid.getStore().load();
+				
 				var btn = Ext.getCmp(oGrid.id+"_filterBtn");
-				if(btn)
+				
+				if(btn) {
 					btn.removeClass("activeFilter");
+				}
+				
+				oFilterHandler.removeAllComponents();
 				oGrid.fireEvent('activate');
 			},
 			





More information about the icinga-checkins mailing list