Numeric format ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Numeric format ?

Lomobob
Hi,

We would like to add a numeric format to some input, but with spaces instead of coma between thousands in big numbers.

An exemple of what we're doing so far:

<xf:input xxf:maxlength="5" xxf:format="if(. castable as xs:decimal) then (translate(format-number(xs:decimal(.), '###,##0.###'),',',' ')) else(.)"/>

When we put a value in this, like "1500", it's working well: it displays "1 500", and in eXist, the recorded value is "1500"

The issue is when we want to correct the value, or just when we focus again on the input field, the space remains; consequently, we have to manualy remove the space to add a fifth number (because of the maxlenght); and if we just remove a 0, the format doesn't apply (because of the space).

To sum up, we would like to have the same behavior as the fr:number compnent, but with ' ' instead of ','

Any idea ?

Ps:

I tried this trick, but it doesn't work either :(

<xf:input id="control-1-control" bind="control-1-bind"
                                          xxf:maxlength="5+string-length(.) - string-length(translate(., ' ', ''))"
                                          xxf:format="if(translate(.,' ','') castable as xs:decimal) then (translate(format-number(xs:decimal(translate(.,' ','')), '###,##0.###'),',',' ')) else(.)"/>

Thanks !

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Numeric format ?

Alessandro  Vernet
Administrator
Hi Lomobob,

Have you tried using the fr:number component? Amongst other things, it allows you to change the grouping separator with oxf.xforms.xbl.fr.number.grouping-separator (you want space instead of coma). For more on this see:

http://doc.orbeon.com/form-runner/component/number.html

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet