Fixes issue 26228: Date and datetime fields are not shown in the tree grid view
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 09 Apr 2014 16:33:20 +0200
changeset 22893 125620fe071d
parent 22892 075221192871
child 22894 62db1949bccc
child 23285 e35a5b38d7ee
Fixes issue 26228: Date and datetime fields are not shown in the tree grid view

The problem was that in the tree grid view the applyCellTypeFormatters was being called passing the date value as a string, when that function expects a date object. This has been solved by detecting this case and converting the value from string to date before calling applyCellTypeFormatters.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Wed Apr 09 15:13:33 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Wed Apr 09 16:33:20 2014 +0200
@@ -139,5 +139,14 @@
   // No actions should be triggered when clicking a record with the right button
   cellContextClick: function (record, rowNum, colNum) {
     return false;
+  },
+
+  applyCellTypeFormatters: function (value, record, field, rowNum, colNum, isMultipleElement) {
+    if (field.type === '_id_16' && value && !isc.isA.Date(value) && isc.isA.Date(Date.parseSchemaDate(value))) {
+      // applyCellTypeFormatters expects a date as value if the field is a date
+      // if the original value is not a date, convert it to date before calling applyCellTypeFormatters
+      value = Date.parseSchemaDate(value);
+    }
+    return this.Super('applyCellTypeFormatters', [value, record, field, rowNum, colNum, isMultipleElement]);
   }
 });
\ No newline at end of file