Fix generic grid model and renderer for virtual fields
authorMichael Spahn <m.spahn@metaways.de>
Tue, 25 Jul 2017 14:02:20 +0000 (16:02 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Tue, 25 Jul 2017 14:41:53 +0000 (16:41 +0200)
Change-Id: Ifffaf27e54919fc04f66e00bb70c0138b9c7a538
Reviewed-on: http://gerrit.tine20.com/customers/5310
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
Tested-by: Michael Spahn <m.spahn@metaways.de>
tine20/Tinebase/js/ApplicationStarter.js
tine20/Tinebase/js/widgets/grid/GridPanel.js

index 48ae47b..2f2bf7f 100644 (file)
@@ -289,6 +289,11 @@ Tine.Tinebase.ApplicationStarter = {
             fieldKey = 'tags';
         }
         var fieldconfig = modelConfig.fields[fieldKey];
+
+        if (fieldconfig && fieldconfig.type === 'virtual') {
+            fieldconfig = fieldconfig.config;
+        }
+
         var appName = modelConfig.appName;
         var modelName = modelConfig.modelName;
         
@@ -398,17 +403,24 @@ Tine.Tinebase.ApplicationStarter = {
                     
                     // iterate record fields
                     Ext.each(modelConfig.fieldKeys, function(key) {
+                        var fieldDefinition = modelConfig.fields[key];
+
+                        if (fieldDefinition.type === 'virtual') {
+                            fieldDefinition = fieldDefinition.config;
+                        }
+
                         // add field to model array
-                        modelArray.push(this.getField(modelConfig.fields[key], key));
-                        
-                        if (modelConfig.fields[key].label) {
+                        modelArray.push(this.getField(fieldDefinition, key));
+
+                        if (fieldDefinition.label) {
                             // register grid renderer
                             if (initial) {
+                                var renderer = null;
                                 try {
-                                    var renderer = this.getGridRenderer(modelConfig.fields[key], key, appName, modelName);
+                                    renderer = this.getGridRenderer(fieldDefinition, key, appName, modelName);
                                 } catch (e) {
                                     Tine.log.err(e);
-                                    var renderer = null;
+                                    renderer = null;
                                 }
                                 
                                 if (Ext.isFunction(renderer)) {
index 2e8f4fb..c1d11b3 100644 (file)
@@ -545,7 +545,11 @@ Ext.extend(Tine.widgets.grid.GridPanel, Ext.Panel, {
             Ext.each(this.modelConfig.fieldKeys, function(key) {
                 var fieldConfig = this.modelConfig.fields[key];
                     globalI18n = (fieldConfig && fieldConfig.hasOwnProperty('useGlobalTranslation'));
-                
+
+                if (fieldConfig.type === 'virtual') {
+                    fieldConfig = fieldConfig.config;
+                }
+
                 // don't show multiple record fields
                 if (fieldConfig.type == 'records') {
                     return true;