0

Force decimalbox to format number always

asked 2009-11-26 04:40:39 +0800

prometeo gravatar image prometeo flag of Italy
43 1 4

Hello

I have a decimalbox with format:
<decimalbox id="decimalbox1" format="#,##0.##" />

For example, it renders numbers like this:

100.11 --> 100.11
100.10 --> 100.1
100.00 --> 100

What if I want to always format at 2 dot decimals?

I cannot find a way to do it, neither a property or constraint.
How could it be done?

Thanks
Best regards
Gianluca Bonetti

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-11-26 04:54:46 +0800

fmcypriano gravatar image fmcypriano
612 1 7
http://felipecypriano.com...

You can create a lang-addon.xml file with this content:

<language-addon>
    <component>
        <component-name>decimalbox</component-name>
        <extends>decimalbox</extends>
        <property>
            <property-name>format</property-name>
            <property-value>#,##0.##</property-value>
        </property>
    </component>
<language-addon>

And in your zk.xml configure it:

    <language-config>
        <addon-uri>/WEB-INF/lang-addon.xml</addon-uri>
    </language-config>

That's it.


Regards,

link publish delete flag offensive edit

answered 2009-11-26 14:54:11 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-11-26 14:55:44 +0800

It's missunderstood. The lang-add-on way is not working for the needed result.

Gianluca will force to fixed two digits.

now rendering
100.11 --> 100.11
100.10 --> 100.1
100.00 --> 100

new rendering
100.11 --> 100.11
100.10 --> 100.10
100.00 --> 100,00

link publish delete flag offensive edit

answered 2009-11-26 15:45:23 +0800

prometeo gravatar image prometeo flag of Italy
43 1 4

Hello

Thanks Felipe and Terry

The lang-addon.xml tip (I didn't know yet) has been useful anyway.
This way I put the format property on every decimalbox without need to specify each time.

I discovered looking around that the correct format string is "#,##0.00"
"#,##0.##" shows decimal part without ending zeroes.
"#,##0.00" shows decimal part always, even if is ends with zeroes.

Thanks everybody!
Bye
Gianluca Bonetti

link publish delete flag offensive edit

answered 2009-11-26 16:17:12 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Great Filipe and Gianluca.

I implemented in this way yet. :-)

link publish delete flag offensive edit

answered 2009-12-02 19:07:30 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

The format pattern will follow Java's DecimalFormat class as possible.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-11-26 04:40:39 +0800

Seen: 971 times

Last updated: Dec 02 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More