Opened 12 years ago

Closed 11 years ago

Last modified 8 years ago

#4477 closed defect (fixed)

Spinner doesn't work properly with places: '0,2'

Reported by: Adam Peller Owned by: Adam Peller
Priority: high Milestone: 1.2
Component: Dijit - Form Version: 0.9
Keywords: Cc: John Locke
Blocked By: Blocking:

Description (last modified by Adam Peller)

From freelock: Setting places:'0,2' results in a NumberSpinner?? that can spin down, but not up, and ignores the smallDelta parameter.

<input dojoType="dijit.form.NumberSpinner?" name="project_budget" id="proj_budget" value="0" size="4" smallDelta="0.25" largeDelta="4" constraints="{min:0.00, max:1000.00, places:'0,2'}"/>

Doug, can you take a look at this? I'm not convinced this is a bug in dojo.number, though it's likely related to #2864, since that added yet another twist to NumberSpinner?. Please reassign back to me or reopen #2864 if you think it's appropriate.

Change History (9)

comment:1 Changed 12 years ago by Adam Peller

Cc: John Locke added

comment:2 Changed 12 years ago by Adam Peller

Milestone: 1.01.1
Owner: changed from Douglas Hays to Adam Peller

a workaround, I think, is to specify pattern:"#.##"

comment:3 Changed 12 years ago by Adam Peller

need to make dojo.number.format handle place ranges as well

comment:4 Changed 12 years ago by Douglas Hays

dojo.number.format(900.25,{places:'0,2'}) is incorectly returning '900'. I think it should be '900.25'. 900.00 should format to '900' with 0,2.

comment:5 Changed 12 years ago by Adam Peller

iirc, that syntax is a range for parsing only. Not sure it makes sense for formatting.

comment:6 Changed 12 years ago by Adam Peller

Milestone: 1.11.2

comment:7 Changed 11 years ago by Paul Barrass

There is also a problem with NumberTextBox? where a "n,m" places constraint is set, with I suspect the same root cause.

With NumberTextBox? and a "n,m" places constraint the decimal part of any intial value is removed. The problem appears to be in dojo.number._formatAbsolute():

	if(options.places){
	    valueParts[1] = dojo.string.pad(fractional.substr(0, options.places), options.places, '0', true);
	}

For the "n,m" case, options.places is a string rather than an integer causing the call to dojo.string.pad to fail. Testing for

(options.places && typeof options.places == "number")

instead will cause the number to be padded based upon pattern rather than upon options.places.

comment:8 Changed 11 years ago by Adam Peller

Description: modified (diff)
Resolution: fixed
Status: newclosed

fixed by [14497]

comment:9 Changed 8 years ago by bill

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