Opened 13 years ago

Closed 13 years ago

Last modified 6 years ago

#5612 closed defect (invalid)

dijit.form.NumberTextBox does not round properly for the 'round' constraint

Reported by: ptwobrussell Owned by: bill
Priority: high Milestone:
Component: Dijit - Form Version: 1.0
Keywords: Cc:
Blocked By: Blocking:


If you specify the round constraint such as <input dojoType="dijit.form.NumberTextBox" constraints="{round:2}"/>, the dijit does not perform any rounding. dojo.number.round seems to work properly, so it seems to be the widget that's the issue.

This defect exists as of version 1.0.2

Change History (4)

comment:1 Changed 13 years ago by Adam Peller

Resolution: invalid
Status: newclosed

there are no decimal places (places or number format) specified here, so there's no rounding to be done. places:2 would round to 2 decimal places, places:2,round:5 would round to the nearest .5 after 2 places. round without places does nothing.

comment:2 Changed 13 years ago by bill

Yes, round can only be use in conjunction with places.

However, the round constraint doesn't do anything with NumberTextBox?, even if you do specify places, since the constraints on the field and the formatting on the field are specified as the same parameter to NumberTextBox?.

Consider the formatting option of {places: 2, round: 5}. It means that numbers should be rounded to 3 decimal places and the third decimal place should either be 0 or 5. For example:

1.33333 ---> 1.330
2.66666 ---> 2.665

Of course, if the original number has <= 2 decimal places, there is no effect.

1.33 --> 1.33
5 --> 5

Now, for NumberTextBox?, if you specify {places: 2, round: 5} as a constraint, the {places: 2} part means that the only input the NumberTextBox? will accept will be with two decimal places. Thus, there will be no rounding.

So this is not something worth changing at this point anyway. I removed "round" from the manual for NumberTextBox?. (The bug might better be closed as "wont fix" than "invalid")

Last edited 6 years ago by bill (previous) (diff)

comment:3 Changed 13 years ago by (none)

Milestone: 1.0.3

Milestone 1.0.3 deleted

comment:4 Changed 10 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.