[OBUISEL] Fixes selected row positioning
authorIván Perdomo <ivan.perdomo@openbravo.com>
Tue, 08 Mar 2011 16:51:39 +0100
changeset 11110 fb8d3320754b
parent 11109 451c8bcaa1cc
child 11111 f86ffe5c4524
[OBUISEL] Fixes selected row positioning
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	Tue Mar 08 16:19:56 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Tue Mar 08 16:51:39 2011 +0100
@@ -105,24 +105,29 @@
 
         requestProperties.params._selectorDefinitionId = this.selector.selectorDefinitionId;
         requestProperties.params._requestType = 'Window';
+
+        if(this.getSelectedRecord()) {
+          requestProperties.params._targetRecordId = this.targetRecordId;
+        }
       },
 
-      dataArrived: function(){
-      
+      dataArrived: function() {
+        var record, rowNum;
         this.Super('dataArrived', arguments);
-        
         // check if a record has been selected, if
         // not take the one
         // from the selectorField
         // by doing this when data arrives the selection
         // will show up
         // when the record shows in view
-        if (!this.getSelectedRecord()) {
-          if (this.selector.getValue()) {
-            this.selectSingleRecord(this.data.find(this.valueField, this.selector.getValue()));
-          } else {
-            this.selectSingleRecord(null);
-          }
+        if (this.targetRecordId) {
+          record = this.data.find(this.selector.valueField, this.targetRecordId);
+          rowNum = this.getRecordIndex(record);
+          this.scrollToRow(rowNum);
+          this.selectSingleRecord(record);
+          delete this.targetRecordId;
+        } else {
+          this.selectSingleRecord(null);
         }
       },
       fields: this.selectorGridFields,
@@ -254,6 +259,7 @@
     // adds the selector id to filter used to get filter information
     defaultFilter._selectorDefinitionId = this.selector.selectorDefinitionId;
     this.defaultFilter = defaultFilter;
+    this.selectorGrid.targetRecordId = this.selector.getValue();
     this.show(true);
   },