Merge branch 'pu/2013.03/modelconfig-hr'
[tine20] / tine20 / Tinebase / js / ApplicationStarter.js
index eb50148..3ff9bea 100644 (file)
@@ -84,6 +84,7 @@ Tine.Tinebase.ApplicationStarter = {
                     fieldDefinition.config.modelName = fieldDefinition.config.modelName.replace(/_/, '');
                     field.type = fieldDefinition.config.appName + '.' + fieldDefinition.config.modelName;
                     break;
+                
             }
             // allow overwriting date pattern in model
             if (fieldDefinition.hasOwnProperty('dateFormat')) {
@@ -165,10 +166,19 @@ Tine.Tinebase.ApplicationStarter = {
                 case 'boolean':
                     gridRenderer = Tine.Tinebase.common.booleanRenderer;
                     break;
+                case 'relation':
+                    var cc = config.config;
+                    gridRenderer = new Tine.widgets.relation.GridRenderer({
+                        appName: appName,
+                        type: cc.type,
+                        foreignApp: cc.appName,
+                        foreignModel: cc.modelName
+                        });
+                    break;
                 default:
                     gridRenderer = Ext.util.Format.htmlEncode;
-                 }
-           }
+            }
+        }
         return gridRenderer;
     },
 
@@ -335,10 +345,15 @@ Tine.Tinebase.ApplicationStarter = {
                             // register grid renderer
                             if (initial) {
                                 var renderer = this.getGridRenderer(modelConfig.fields[key], key, appName, modelName);
-                                if (renderer) {
+                                
+                                if (Ext.isFunction(renderer)) {
                                     if (! Tine.widgets.grid.RendererManager.has(appName, modelName, key)) {
                                         Tine.widgets.grid.RendererManager.register(appName, modelName, key, renderer);
                                     }
+                                } else if (Ext.isObject(renderer)) {
+                                    if (! Tine.widgets.grid.RendererManager.has(appName, modelName, key)) {
+                                        Tine.widgets.grid.RendererManager.register(appName, modelName, key, renderer.render, null, renderer);
+                                    }
                                 }
                             }
                         }