Fixes issue 28229: Lazy Filtering works properly in P&E windows
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 19 Nov 2014 18:09:26 +0100
changeset 24100 38f1e85d7ae1
parent 24099 7ba7947fde99
child 24101 f0f3d691ee2a
Fixes issue 28229: Lazy Filtering works properly in P&E windows

There was a problem when the button to apply the current filters (only shown when lazy filtering is configured for a tab) was pressed in a P&E window. If the filters were not changed before pressing the button, the grid.refreshGrid function was invoked, and this function was not defined for P&E windows. This function has been defined now. Also, a flag has been added to detect when the filterClause is removed, to allow refreshing the grid in that case even if the filter editor is not changed.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
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/grid/ob-grid.js	Thu Nov 20 11:48:06 2014 +0530
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Nov 19 18:09:26 2014 +0100
@@ -628,7 +628,9 @@
           if (!this._iconEnabled) {
             return;
           }
-          if (grid.filterHasChanged) {
+          if (grid.filterHasChanged || grid.filterClauseJustRemoved) {
+            // the filter clause can only be removed once
+            delete grid.filterClauseJustRemoved;
             // Do not change the sorting after receiving the data from the datasource
             grid._filteringAndSortingManually = true;
             grid.filterEditor.performFilter(true, true);
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Thu Nov 20 11:48:06 2014 +0530
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Wed Nov 19 18:09:26 2014 +0100
@@ -528,6 +528,10 @@
   },
 
   clearFilter: function () {
+    if (this.lazyFiltering && this.filterClause) {
+      // store that the filter has been removed to enable showing potential new records
+      this.filterClauseJustRemoved = true;
+    }
     this.filterClause = null;
     this._cleaningFilter = true;
     this.contentView.messageBar.hide();
@@ -829,6 +833,11 @@
     } else {
       this.Super('getMinFieldWidth', arguments);
     }
+  },
+
+  refreshGrid: function () {
+    // fetch the data with the current criteria and context info
+    this.filterData(this.getCriteria(), null, this.getContextInfo());
   }
 
 });
\ No newline at end of file