Feature #246
Fromatting numbers to blank if zero
0%
Description
Could be great if we could format numbers to blank if zero. For example $numberFormat("B #,###.00",$number)
I know that replacing zero values to null and using the silent sign could do that, but doing that causes wrong results when doing calculation inside the template.
If I do: #set($Total=$amount1+$amount2+$amount3) and one of the amounts is null nothing is stores into $Total.
I badly need that because I have a report that shows a crosstab with dates and hours with many zeros and the customer is complaining about that.
Thanks.
History
Updated by Patrick Talbot about 14 years ago
- Tracker changed from Defect to Feature
Problem is that there is no zero formatter for numbers in Java.
One could maybe achieve something like that using a conditional formater, but that's not an easy thing to add (btw, this is a feature request, not a defect).
Alternatively, I could add a special property to $number.format(), but that's also some work which I didn't really plan.
Depending on how badly you/your customer needs it, would you consider sponsoring it?
Updated by Patrick Talbot almost 13 years ago
- Category set to overall
- Priority changed from Normal to Low
- Client type set to Any
- In developer? set to No
- Servoy version set to Any
- Component version set to v2.0
- OS version set to Any
- Java version set to Any
Updated by Patrick Talbot over 12 years ago
- Status changed from New to In Progress
Added $number.nullIfZero($aNumber).
This will allow you to do something like this:
$!number.format("# ###.00 $", $number.nullIfZero($aNumber))
Which will show as blank if $aNumber is 0
Updated by Patrick Talbot over 12 years ago
- Status changed from In Progress to Closed
#number.nullIfZero is present with v2.0.27+