Hello, i have a weird situation i can't get my head around.
I have a listgrid with a lot of float columns in the datatype like this:
All works well, it prints 8.76, 3.15, and 0.00 for zero. However, I want the fields that are zero to be blanked out, so i'm trying to add a cellformatter
my code:
The problem is that the object o that gets called in the formatter is now an integer! so now all cells are 0, 1 etc. I would have expected the formatter to be called with a float object.
Am i doing something wrong?
EDIT: From the Cellformatter javadoc: "value - raw value for the cell, from the record for the row". This appears to not be the case, since the class of the value is int even though the datatype is float.
EDIT2: It seems as though the class of the value differs whether the value is a fraction or a whole value! So, if it's 8.5 its a double, if its 8.0 its an int. This does not match the javadoc? Nor what i would expect.
It also makes the cellformatter harder to write since i basically must check for the class for each cell in order to be able to do formatting.
I have a listgrid with a lot of float columns in the datatype like this:
Code:
<field name="d6" type="float" title="6" required="true" format="0.00"/>
my code:
Code:
CellFormatter setZeroBlankFormatter = new CellFormatter() { @Override public String format(Object value, ListGridRecord listGridRecord, int i, int i1) { System.out.println("Formatting "+ value.toString() + ", type: " + value.getClass());//this is just me trying since i cant get it to work return ""+o; } }; ListGridField[] fields = grid.getFields(); for (ListGridField field : fields) { if(field.getName().startsWith("d")){ field.setCellFormatter(setZeroBlankFormatter); } }
Am i doing something wrong?
EDIT: From the Cellformatter javadoc: "value - raw value for the cell, from the record for the row". This appears to not be the case, since the class of the value is int even though the datatype is float.
EDIT2: It seems as though the class of the value differs whether the value is a fraction or a whole value! So, if it's 8.5 its a double, if its 8.0 its an int. This does not match the javadoc? Nor what i would expect.
It also makes the cellformatter harder to write since i basically must check for the class for each cell in order to be able to do formatting.
Comment