-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi In the list box, one of the column, i have the decimal box as shown.
<listcell
onClick="@command('onListCellClick',lineItem=p1)">
<decimalbox cols="25"
onChange="@command('doTotal')" instant="true"
value="@bind(p1.postingAllowedAmt)" mold="rounded"
format="####.##" hflex="1" />
</listcell>
Problem here is when user want to type with decimal values, say for example 30.05, then after entering 30, and after entering the dot , quickly the dot disappears and whatever entered it becomes whole number like 3005.
How to correct this problem
Already known issue. Depends on your locale.
See here for the the discutions : http://forum.zkoss.org/question/49959/how-to-tell-to-all-decimalboxes-and-doubleboxes-in-application-to-take-dot-as-decimal-separator/
if you check the documentation on instant="true"
you can see the value is instantly sent to the server, parsed/validated and returned.
Therefore the decimal point is removed if you are not quick enough (by default 350ms). If you type the next digit within 350ms the decimal point will not be removed.
That's the side effect "instant=true", without it, the widget will wait until the input has lost focus, before sending the information to the server.
To increase the delay you can add this script to your page (see here)
<?script content="zk.afterLoad('zul.inp',function({zul.inp.InputWidget.onChangingDelay=1000;})"?>
Robert
Hi Senthil,
Decimal box as any other NumberInputElement is locale specific. So in order to get a specific formatting use the locale like this. If you don't specify it, it will assume the server default locale. The format string will ususally be the same but the formatted output and parsed input will use locale specific group- and decimal-separators.
e.g.
<zk>
<grid width="300px">
<rows>
<row>
DE locale <decimalbox locale="de" format="#,###.##" value="2000.50"/>
</row>
<row>
EN locale <decimalbox locale="en" format="#,###.##" value="2000.51"/>
</row>
</rows>
</grid>
</zk>
Also see: http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
Regards,
Robert
Thanks robert. But when i remove the instant = true, every thing works fine.
Thank you robert.
Even after increasing the delay, still have the same problem. For time being, i am using with onBlur event (lost focus)
This is really killing me. Even though i have included the following script in the top
<?script content="zk.afterLoad('zul.inp',function({zul.inp.InputWidget.onChangingDelay=1000;})"?>
But still the following code giving me the problem
<decimalbox id="amount"
cols="25" mold="rounded" format="#,###.##" hflex="1"
name="fee" readonly="@load(vm.makeAsReadOnly)"
value="@bind(fx.amount)" />
Here is the problem
Wow, even in zk demo itself having the same problem
In the weight box, type 45. and do alt tab in windows and then come back, you can see dot has been removed.
when typing ALT-TAB the component loses its focus and applies the format. I don't see a problem there. the "onChangingDelay=1000" will only affect the delay while typing and not the formatting onChange (after focus lost). How do you expect the value to be updated if not onBlur ??
cor3000 ( 2014-02-26 14:09:57 +0800 )editThank you Robert. But it is giving major problem for me. Current application is accounting system application, where user will be entering the values as per the statement received from the bank as pdf. So they will open the PDF and my application, use alt tab to navigate between two windows to enter the values.
Hi Senthil,
You can handle number formatting yourself to format the number as your need (e.g., always keep '.' and display error message if a number ends with '.' while save button clicked), for more information please refer to the related article at my blog: ZK Decimalbox Support Scientific Notation
You can also view the source code directly.
The character '#' in the format string "####.##" means that the non-significant zero digits would not be displayed. When the focus is lost (e.g. tab to another input widget or switch to another browser tab), decimalbox would think the "entering value phase" has finished, and would apply the format. If the value is "45." at this moment, applying the format would remove the decimal point since the fractional part is zero.
The following is a way to solve the "value entering" interruption issue.
See zkfiddle example
Asked: 2014-01-30 13:16:57 +0800
Seen: 91 times
Last updated: Feb 13 '15