Fixed issue 28242: Load grid even with inconsistent default view info
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 25 Nov 2014 12:08:01 +0100
changeset 24104 5870e500427a
parent 24103 61723aeb4392
child 24105 fc76bf005885
Fixed issue 28242: Load grid even with inconsistent default view info

Before the previous changeset was applied, it was possible to have a preference that specified that a certain grid had a default saved view, but that the referenced default saved view did not actually exists. When this happened the grid was not loaded until the user pressed the Refresh button.

To fix this, now the inconsistent default view info is detected and the grid is loaded once it is detected that the default view does not actually exists.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Tue Nov 25 11:51:55 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Tue Nov 25 12:08:01 2014 +0100
@@ -369,6 +369,8 @@
       if (!lazyFiltering) {
         if (!this.standardWindow.checkIfDefaultSavedView()) {
           this.viewGrid.fetchData(this.viewGrid.getCriteria());
+        } else {
+          this.dataLoadDelayedForDefaultSavedView = true;
         }
       }
       this.refreshContents = false;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Tue Nov 25 11:51:55 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Tue Nov 25 12:08:01 2014 +0100
@@ -519,8 +519,8 @@
 
     // find the default view, the personalizations are
     // returned in order of prio, then do sort by name
-    if (this.getClass().personalization.views) {
-      views = this.getClass().personalization.views;
+    views = this.getClass().personalization.views;
+    if (views && isc.isA.Array(views) && views.length > 0) {
       length = views.length;
 
       this.getClass().personalization.views.sort(function (v1, v2) {
@@ -569,6 +569,13 @@
           }
         }
       }
+    } else {
+      if (this.view.dataLoadDelayedForDefaultSavedView) {
+        // it might happen that the load of the initial grid data was delayed because it had a 
+        // default saved view, but then the default saved view is not returned by the WindowSettingsActionHandler.
+        // in that case, detect it and load the grid now
+        this.view.viewGrid.fetchData(this.view.viewGrid.getCriteria());
+      }
     }
 
     // restore focus as the focusitem may have been hidden now