Browse Source

从表columns中存在summary时才构建合计栏

zhuth 7 years ago
parent
commit
acf8c731fe
1 changed files with 21 additions and 10 deletions
  1. 21 10
      frontend/saas-web/app/view/core/form/field/DetailGridField.js

+ 21 - 10
frontend/saas-web/app/view/core/form/field/DetailGridField.js

@@ -25,18 +25,9 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
     showIndex: true,
     configUrl: '',
 
-    features: [{
-        ftype : 'groupingsummary',
-        groupHeaderTpl : '{name}',
-        hideGroupedHeader : false,
-        enableGroupingMenu : false
-    }, {
-        ftype: 'summary',
-        dock: 'bottom'
-    }],
-
     initComponent: function() {
         var me = this;
+        me.setSummary();
         Ext.apply(me, {
             dockedItems: [{
                 xtype: 'toolbar',
@@ -86,6 +77,26 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
         }
     },
 
+    setSummary: function() {
+        var me = this,
+        columns = me.columns,
+        features = me.features || [];
+
+        var hasSummary = !!columns.find(function(c) {
+            return c.summaryType
+        });
+
+        if(hasSummary) {
+            features.push({
+                ftype: 'summary',
+                dock: 'bottom'
+            });
+        }
+        Ext.apply(me, {
+            features: features
+        });
+    },
+
     add10EmptyRow: function() {
         var me = this,
         form = me.ownerCt,