Fixes issue 20229: Combo product selector in grid mode is not working properly
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 03 May 2012 11:15:09 +0200
changeset 16366 080a243f3f16
parent 16365 9a7580f8f358
child 16367 0a67797edc70
Fixes issue 20229: Combo product selector in grid mode is not working properly

The problem was caused because the same combo is shared among all the records, and it was not being properly reset when a new row was created. Now, when a new row is created, the previous highlighted combo option is cleared and the first option is selected.
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu May 03 10:43:29 2012 +0200
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu May 03 11:15:09 2012 +0200
@@ -376,11 +376,25 @@
           }
         }
       }
+    } else { //Select by default the first option in the picklist, if possible
+      this.selectFirstPickListOption();
     }
 
     this.Super('setValue', arguments);
   },
 
+  selectFirstPickListOption: function () {
+    var firstRecord;
+    if (this.pickList) {
+      if (this.pickList.data && (this.pickList.data.totalRows > 0)) {
+        firstRecord = this.pickList.data.get(0);
+        this.pickList.selection.selectSingle(firstRecord);
+        this.pickList.clearLastHilite();
+        this.pickList.scrollRecordIntoView(0);
+      }
+    }
+  },
+
   // changed handles the case that the user removes the value using the keyboard
   // this should do the same things as setting the value through the pickvalue
   changed: function (form, item, newValue) {