Fixes bug 25666: Columns are not wrongly updated when chaging rows in the grid
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 06 Feb 2014 09:53:55 +0100
changeset 21997 5571b88ed3f0
parent 21996 fd2c8a575d9f
child 21998 360a837f23db
Fixes bug 25666: Columns are not wrongly updated when chaging rows in the grid

This issue happened when the user clicked on a record (this triggers a FIC call) and then clicked on another record before the FIC response was received. What
was happening is that the FIC response was applied on the currently selected row, not on the row that trigger the FIC call. This has been fixed by checking bef
ore the FIC response is processed if the selected row has changed.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Tue Feb 04 16:12:14 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Feb 06 09:53:55 2014 +0100
@@ -2178,7 +2178,7 @@
   setContextInfo: function (sessionProperties, callbackFunction, forced) {
     var newCallback, me = this,
         gridVisibleProperties = [],
-        len, i;
+        len, i, originalID;
     // no need to set the context in this case
     if (!forced && (this.isEditingGrid || this.isShowingForm)) {
       if (callbackFunction) {
@@ -2192,13 +2192,23 @@
       sessionProperties = this.getContextInfo(false, true, false, true);
     }
 
+    if (this.viewGrid && this.viewGrid.getSelectedRecord()) {
+      originalID = this.viewGrid.getSelectedRecord()[OB.Constants.ID];
+    }
+
     newCallback = function (response, data, request) {
       var context = {},
-          grid = me.viewGrid;
-      context.rowNum = grid.getRecordIndex(grid.getSelectedRecord());
+          grid = me.viewGrid,
+          currentRecord, currentID;
+      currentRecord = grid.getSelectedRecord();
+      context.rowNum = grid.getRecordIndex(currentRecord);
+      currentID = currentRecord[OB.Constants.ID];
       context.grid = grid;
       response.clientContext = context;
-      grid.processFICReturn(response, data, request);
+      if (originalID === currentID) {
+        // Only update the grid if the user has not changed rows
+        grid.processFICReturn(response, data, request);
+      }
       if (callbackFunction) {
         callbackFunction();
       }