Fixes Issue 0024692: Double request to the datasource is done when a numeric field is in the first position of the grid
authorShankar Balachandran <shankar.balachandran@openbravo.com>
Wed, 25 Sep 2013 13:28:36 +0530
changeset 21191 327a7d8af6ce
parent 21190 f71255ba7557
child 21192 8ab8b14e8472
Fixes Issue 0024692: Double request to the datasource is done when a numeric field is in the first position of the grid

The filter in blur event needs to be applied only if the value is not undefined.
In case there is value in the filter and then the value is cleared,
still the filter will be applied because the value returned will be null and not undefined.
Also the additional datasource call will be avoided as in that case, the value is undefined.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Wed Sep 25 10:20:15 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Wed Sep 25 13:28:36 2013 +0530
@@ -593,7 +593,11 @@
 
   // If the filter has not been applied yet, apply it when it loses the focus
   blur: function () {
-    if (this.form && this.form.getFocusItem() !== this) {
+    var undef;
+    //do not apply the filter if the value is undefined. Can happen in cases where a record is opened directly and creates an additional datasource call.
+    //Refer issue https://issues.openbravo.com/view.php?id=24692
+    //if there was an existing value in filter and it is removed, the getValue() returns null, so the filter will be removed to show all values.
+    if (this.getValue() !== undef) {
       this.form.grid.performAction();
     }
     return this.Super('blur', arguments);