fixes issue 29560: added function to check if the data is loaded in p&e grids
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 16 Apr 2015 10:13:54 +0200
changeset 26327 7b71a49c0644
parent 26326 ec14efbe7ce6
child 26328 12ef70e78186
fixes issue 29560: added function to check if the data is loaded in p&e grids

A check is added to prevent the execution of the on grid load functions if the local data is not loaded.
This problem could happen when a request is done and the load of a previous request has not finished.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Tue Apr 14 18:56:15 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Thu Apr 16 10:13:54 2015 +0200
@@ -503,6 +503,12 @@
     this.Super('handleFilterEditorSubmit', [crit, context]);
   },
 
+  isDataLoaded: function () {
+    // When the data is being loaded, every element in the localData array is set with the "loading" value
+    // So we just need to check the first position of the array
+    return this.data.localData && !Array.isLoading(this.data.localData[0]);
+  },
+
   dataArrived: function (startRow, endRow) {
     var record, i, rows, selectedLen = this.selectedIds.length,
         len, savedRecord, index, j, fields, allRequiredSet;
@@ -547,7 +553,9 @@
     }
 
     this.Super('dataArrived', arguments);
-    if (this.onGridLoadFunction) {
+    // See issue 29560: check if the local data is loaded to execute the on grid load function
+    // This prevents errors when a request is done and the load of a previous request has not finished
+    if (this.onGridLoadFunction && this.isDataLoaded()) {
       this.onGridLoadFunction(this);
       this.view.handleButtonsStatus();
     }