Related to issue 19805: Modify grid properties of String and Foreign Key fields
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 27 Feb 2012 11:18:21 +0100
changeset 15624 5d04ccfa2cd8
parent 15623 14313dc2eac4
child 15625 4d25a7e6f421
Related to issue 19805: Modify grid properties of String and Foreign Key fields

Include info about the length of ForeignKeyUIDefinition in the getGridFieldProperties method. Edit the info about the length of StringUIDefinition so it is taken from field.getDisplayedLength() istead of field.getColumn().getLength(). This length info is then used to select the field that will be automatically expanded in the grid (if any).
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Mon Feb 27 10:30:45 2012 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Mon Feb 27 11:18:21 2012 +0100
@@ -48,12 +48,18 @@
   public String getGridFieldProperties(Field field) {
     final Property prop = KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
 
+    Long length = field.getDisplayedLength();
+    if (length == null || length == 0) {
+      length = field.getColumn().getLength();
+    }
+    String lengthProperty = length != null ? ", length:" + length : "";
+
     // only output when really needed
     String displayField = "";
     if (getDisplayFieldName(field, prop) != null) {
       displayField = ", displayField: '" + getDisplayFieldName(field, prop) + "'";
     }
-    return displayField + ",fkField: true" + super.getGridFieldProperties(field)
+    return displayField + lengthProperty + ",fkField: true" + super.getGridFieldProperties(field)
         + getShowHoverGridFieldSettings(field);
   }
 
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java	Mon Feb 27 10:30:45 2012 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java	Mon Feb 27 11:18:21 2012 +0100
@@ -44,7 +44,10 @@
 
   @Override
   public String getGridFieldProperties(Field field) {
-    Long length = field.getColumn().getLength();
+    Long length = field.getDisplayedLength();
+    if (length == null || length == 0) {
+      length = field.getColumn().getLength();
+    }
 
     // custom override
     if (field.getColumn().getDBColumnName().compareToIgnoreCase("documentno") == 0) {