details:   https://code.openbravo.com/erp/devel/pi/rev/02db9cb1d672
changeset: 28620:02db9cb1d672
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Fri Feb 19 11:21:21 2016 +0100
summary:   fixes issue 32287: Selection can be lost in P&E grids under some 
circumstances

If we refresh the grid, after selecting a record in a page different from the 
first one, Smartclient internally prepares the request to retrieve the records 
surrounding the selected one, in order to try to keep the position of the 
scroll.

This behavior in P&E can cause the losing of the selected records, because they 
are always loaded on the first page. In order to prevent this, we detect this 
situation in P&E grids before performing the request, and in that case we adapt 
it to force the retrieval of the first page which contains all the selected 
records.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
 |  15 ++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diffs (32 lines):

diff -r 7bf022753248 -r 02db9cb1d672 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
      Fri Feb 19 10:44:55 2016 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
      Fri Feb 19 11:21:21 2016 +0100
@@ -191,6 +191,14 @@
         isc.addProperties(dsRequest.originalData, 
me.addSelectedIDsToCriteria());
       }
       dsRequest.params[OB.Constants.IS_PICK_AND_EDIT] = true;
+      if (!me.firstRecordWillHaveValue()) {
+        // The request has been fired having scroll out of the first page
+        // We prepare startRow, endRow and localData to ensure that all the 
selected records will be returned from the server
+        dsRequest.startRow = 0;
+        dsRequest.endRow = me.dataPageSize;
+        me.data.localData = [];
+        me.data.setRangeLoading(dsRequest.startRow, dsRequest.endRow);
+      }
       return this.Super('transformRequest', arguments);
     };
     filterableProperties = this.getFields().findAll('canFilter', true);
@@ -629,6 +637,13 @@
     return this.data.localData && !Array.isLoading(this.data.localData[0]);
   },
 
+  firstRecordWillHaveValue: function () {
+    // localData[0] = value, a new page has been requested (scroll down)
+    // localData[0] = "loading", first page has been requested
+    // localData[0] = undefined, a grid refresh has been requested having 
scroll out of the first page
+    return this.data.localData[0] !== undefined;
+  },
+
   dataArrived: function (startRow, endRow) {
     var record, i, rows, selectedLen = this.selectedIds.length,
         len, savedRecord, index, j, fields, allRequiredSet;

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to