# HG changeset patch
# User Augusto Mauch <augusto.mauch@openbravo.com>
# Date 1395158147 -3600
# Node ID 3db943da9a63bd6f7fdaad404abcccfbb9f59d73
# Parent  cd584099129d2b6b424556fa1b962adfdff75bb5
Fixes issue 25987: Is impossible to edit a record in parameter tab in grid view

The problem was that smartclient's getField function does not work properly if the 'length' field is requested. Instead of returning the 'length' field definition, it returns the length of the fields array.

This has been fixed by overwritting the getField function, and using this.fields.find(this.fieldIdProperty, 'length'); if the 'length' field is requested. If a field other than 'length' is requested, it returns this.Super('getField', arguments);

diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
@@ -1086,6 +1086,17 @@
       return this.Super('getSortArrowImage', arguments);
     }
 
+  },
+
+  // smartclient's getField function does not work properly if the 'length' field is requested
+  // instead of returning the 'length' field definition, it returns the length of the fields array
+  // see https://issues.openbravo.com/view.php?id=25987, http://forums.smartclient.com/showthread.php?p=117505#post117505
+  getField: function (id) {
+    if (id === 'length') {
+      return this.fields.find(this.fieldIdProperty, id);
+    } else {
+      return this.Super('getField', arguments);
+    }
   }
 });
 
