fixes issue 33669: Extra DS call after opening window with summaries on subtabs
authorCarlos Aristu <carlos.aristu@openbravo.com>
Wed, 10 Aug 2016 14:24:36 +0200
changeset 30085 eec30a5fcdf4
parent 30084 c070107d842a
child 30086 88ea14de1a84
fixes issue 33669: Extra DS call after opening window with summaries on subtabs

An unneeded datasource request was being fired after opening a window having summary functions on a child tab. This was caused because the getSummaryRow() is invoked when drawing the window components. If the summaryRow is already generated at this point, the summaries are recalculated by Smartclient.
In this case, the request is not needed, because the summaries in the child tab will never have any value as no record is selected on the parent.
To prevent this extra request, the grid now checks in the getSummaryRow() whether it is located in a child view and in this case, if the parent grid is being loaded, then the request will not be fired.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Tue Aug 09 14:06:03 2016 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Aug 10 14:24:36 2016 +0200
@@ -906,9 +906,21 @@
       }
       return this.summaryRow;
     }
+    if (this.summaryRow && this.isParentGridFetchingData()) {
+      // return the summaryRow if the grid is child of another grid whose data is being fetched
+      // this prevents unneeded datasource requests by not calling the Super 'getSummaryRow' function
+      return this.summaryRow;
+    }
     return this.Super('getSummaryRow');
   },
 
+  isParentGridFetchingData: function () {
+    if (this.view && this.view.parentView && this.view.parentView.viewGrid) {
+      return this.view.parentView.viewGrid.isFetchingData();
+    }
+    return false;
+  },
+
   // puts the grid in a state pending of recalculate summaries
   markForCalculateSummaries: function () {
     if (!this.lazyFiltering) {