← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3065: Removing decimals from html grid values, affecting report table, completeness report

 

------------------------------------------------------------
revno: 3065
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-03-18 09:17:37 +0100
message:
  Removing decimals from html grid values, affecting report table, completeness report
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java	2011-03-03 18:29:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java	2011-03-18 08:17:37 +0000
@@ -29,6 +29,7 @@
 
 import java.text.DateFormat;
 import java.text.DateFormatSymbols;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -43,6 +44,9 @@
  */
 public class I18nFormat
 {
+    private static final DecimalFormat FORMAT_DOUBLE = new DecimalFormat( "#.#;#.#" ); // Fixed for now
+    private static final String EMPTY = "";
+    
     private ResourceBundle resourceBundle;
 
     public I18nFormat( ResourceBundle resourceBundle )
@@ -179,6 +183,11 @@
         return Character.toUpperCase( startDate.charAt( 0 ) ) + startDate.substring( 1 ) + endDate;
     }
     
+    public String formatValue( Object value )
+    {
+        return value != null ? FORMAT_DOUBLE.format( value ) : EMPTY;
+    }
+    
     // -------------------------------------------------------------------------
     // Support methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm	2011-01-14 16:14:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm	2011-03-18 08:17:37 +0000
@@ -30,7 +30,11 @@
 <tr>
 #foreach( $col in $row )
 #set( $index = ( $velocityCount - 1 ) )
-<td #if( $grid.getVisibleHeaders().get( $index ).meta )style="text-align:left"#end>$!encoder.htmlEncode( $col )</td>
+#if( $grid.getVisibleHeaders().get( $index ).meta )
+<td style="text-align:left">$!encoder.htmlEncode( $col )</td>
+#else
+<td>$!format.formatValue( $col )</td>
+#end
 #end
 </tr>
 #end