[icinga-checkins] icinga.org: icinga-web/mhein/default: * Fixed grids not showing when js load delay was to big

git at icinga.org git at icinga.org
Thu Sep 16 17:14:04 CEST 2010


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

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Thu Sep 16 10:33:04 2010 +0200

* Fixed grids not showing when js load delay was to big

---

 app/modules/Cronks/lib/js/grid/MetaGridCreator.js |  123 ++++++++++++---------
 1 files changed, 73 insertions(+), 50 deletions(-)

diff --git a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
index 94cb2ef..2338fc7 100755
--- a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
+++ b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
@@ -20,14 +20,24 @@ Cronk.grid.MetaGridCreator = function(meta) {
 	grid_events = {},
 		
 	addGridMethods = function(config, colIndex, colItem) {
-		Ext.each(config, function(item, fIndex, allItem) {
-			
-			var cb = createGridCallback(item, colItem);	
-			
+
+		Ext.each(config,function(item, fIndex, allItem) {
+			addConfigGridMethod(item, fIndex, allItem,colItem,colIndex);
+		}, this);
+	
+	},
+
+	addConfigGridMethod  = function(item, fIndex, allItem, colItem,colIndex) {
+		/**
+		 * Fixes timing issues - when the callback function is not yet initialized the function
+		 * will be called later on
+		 */
+		var cb = createGridCallback(item, colItem);
+		if(cb) {
 			if (Ext.isEmpty(item.type)) {
 				item.type = 'renderer';
 			}
-			
+
 			if (item.type == 'renderer') {
 				pub.column_array[colIndex].renderer = cb;
 			}
@@ -37,59 +47,72 @@ Cronk.grid.MetaGridCreator = function(meta) {
 			else {
 				addGridEvent(item, cb);
 			}
+		} else {
+			addConfigGridMethod.defer(100,this,[item, fIndex, allItem, colItem,colIndex])
+		}
 
-		}, this);
 	},
-		
+
 	createGridCallback = function(struct, columnName) {
 		
 		// AppKit.log(struct);
-		
-		if (Ext.isEmpty(struct.type)) {
-			struct.type = 'renderer';
-		}
-		
-		if (!Ext.isEmpty(struct['function'])) {
-			
-			var ns = null;
-			var f = null;
-			
-			if (!Ext.isEmpty(struct.namespace)) {
-				ns = struct.namespace;
-				f = Ext.decode(struct.namespace + '.' + struct['function']);
-			}
-			else {
-				f = Ext.decode(struct['function']);
-			}
-			
-			if (!Ext.isEmpty(columnName)) {
-				var c = Ext.apply({field: columnName}, struct['arguments'] || {});
-				var tmp = f.call(this, c);
-				f = tmp;
-			}
-			else {
-				
-				var c = {
-					oGrid: pub.getGrid(),
-					oStore: pub.getStore(),
-					oMeta : pub.getMeta(),
-					oCreator: pub
-				};
-				
-				Ext.apply(c, struct['arguments'] || {});
-				var tmp = f.createDelegate(ns || f, [c], true);
-				
-				f = tmp;
+		try {
+			if (Ext.isEmpty(struct.type)) {
+				struct.type = 'renderer';
 			}
 
-			if (Ext.isFunction(f)) {
-				return {
-					fn: f,
-					scope: (ns || f)
-				};
+			if (!Ext.isEmpty(struct['function'])) {
+
+				var ns = null;
+				var f = null;
+
+				if (!Ext.isEmpty(struct.namespace)) {
+					ns = struct.namespace;
+					f = Ext.decode(struct.namespace + '.' + struct['function']);
+				}
+				else {
+					f = Ext.decode(struct['function']);
+
+				}
+
+				if (!Ext.isEmpty(columnName)) {
+					var c = Ext.apply({field: columnName}, struct['arguments'] || {});
+					var tmp = f.call(this, c);
+					f = tmp;
+				}
+				else {
+
+					var c = {
+						oGrid: pub.getGrid(),
+						oStore: pub.getStore(),
+						oMeta : pub.getMeta(),
+						oCreator: pub
+					};
+
+					Ext.apply(c, struct['arguments'] || {});
+					var tmp = f.createDelegate(ns || f, [c], true);
+
+					f = tmp;
+				}
+
+				if (Ext.isFunction(f)) {
+					return {
+						fn: f,
+						scope: (ns || f)
+					};
+				}
+
+				throw("createGridCallback: no function comes back!");
+			}
+		} catch(e) {
+			switch(e) {
+				//check and rethrow
+				case "createGridCallback: no function comes back!":
+					throw("createGridCallback: no function comes back!");
+					break;
+				default:
+					return false;
 			}
-			
-			throw("createGridCallback: no function comes back!");
 		}
 	},
 		





More information about the icinga-checkins mailing list