Related with bug 28246: Filter expression not reset after clearing the filters
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 26 Nov 2014 13:38:02 +0100
changeset 25407 0bdb0cb683ed
parent 25406 3702a2c3cb7e
child 25408 30e8d84ac147
Related with bug 28246: Filter expression not reset after clearing the filters

The following problem has been detected while doing the QA for issue 28246: If a grid parameter has a display logic and a filter expression, then when the user clears the filter the filter expression will be momentarily removed, and then reset again.

This happened because there was some code that tried to guarantee that the grid was loaded the first time that is was made visible and that had the filter expression applied, but was not checking properly that the grid was not loaded yet. This resulted in reapplying the filter expression each time the grid is redrawn.

This has been fixed by checking properly if the grid has already loaded its data (in that case its data property will be an instance of ResultSet).
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Mon Dec 08 10:38:25 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Wed Nov 26 13:38:02 2014 +0100
@@ -190,14 +190,17 @@
       } catch (_exception) {
         isc.warn(_exception + ' ' + _exception.message + ' ' + _exception.stack);
       }
-      if (item.getType() === 'OBPickEditGridItem') {
-        if (originalShowIfValue && item.defaultFilter !== null && !isc.isA.emptyObject(item.defaultFilter)) {
-          item.canvas.viewGrid.setFilterEditorCriteria(item.defaultFilter);
-          item.canvas.viewGrid.filterByEditor();
-        } else if (originalShowIfValue && item.canvas && item.canvas.viewGrid && !isc.isA.ResultSet(item.canvas.viewGrid.data)) {
-          // if the item is a grid that has display logic and is being displayed for the 
-          // first time (its data is not a ResultSet), load it 
-          item.canvas.viewGrid.refreshGrid();
+      if (originalShowIfValue && item.getType() === 'OBPickEditGridItem') {
+        // load the grid if it is being shown for the first time
+        if (item.canvas && item.canvas.viewGrid && !isc.isA.ResultSet(item.canvas.viewGrid.data)) {
+          if (item.defaultFilter !== null && !isc.isA.emptyObject(item.defaultFilter)) {
+            // if it has a default filter, apply it and use it when filtering
+            item.canvas.viewGrid.setFilterEditorCriteria(item.defaultFilter);
+            item.canvas.viewGrid.filterByEditor();
+          } else {
+            // if it does not have a default filter, just refresh the grid
+            item.canvas.viewGrid.refreshGrid();
+          }
         }
       }
       if (this.view && this.view.theForm) {