Fixes issue 30062: Grid is properly loaded after refreshing with a selected row
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 04 Jun 2015 14:54:06 +0200
changeset 26854 82e40910201d
parent 26853 0a83fa5e05c1
child 26855 672ff4b32ead
child 26859 aa05c3f56c97
Fixes issue 30062: Grid is properly loaded after refreshing with a selected row

The problem was caused by this code (the this attribute is a ResultSet), which is contained in the fetchRemoteData function:

} else if (this.grid.refreshingWithSelectedRecord) {
// if the grid was refreshed with a record selected, use the range that contained that record
// instead of using targetRecordId to improve the performance
startRow = this.grid.selectedRecordInitInterval;
endRow = this.grid.selectedRecordEndInterval;
}

If the grid is refreshed while one of its records is selected, then the startRow and endRow will be set so that the requested page contains the selected record. The problem was that the ResultSet.localData attribute was not being properly set, as at this points it was expected to contain the 'loading' value for all the rows that are being requested. As a result of this the localData attribute became malformed when the response was processed, and this caused the grid to misbehave.

To fix this, the localData is configured to wait for the proper records:

this.localData = [];
this.setRangeLoading(startRow, endRow);
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Thu Jun 04 12:25:19 2015 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Thu Jun 04 14:54:06 2015 +0200
@@ -217,6 +217,10 @@
         //  instead of using targetRecordId to improve the performance
         startRow = this.grid.selectedRecordInitInterval;
         endRow = this.grid.selectedRecordEndInterval;
+        // the startRow and endRow are being modified, so the localData attribute also
+        // needs to be updated to wait for the proper records
+        this.localData = [];
+        this.setRangeLoading(startRow, endRow);
       }
       return this.Super('fetchRemoteData', arguments);
     },