dijit/form/NumberTextBox.Mixin (version 1.10)

Summary

A mixin for all number textboxes

See the dijit/form/NumberTextBox.Mixin reference documentation for more information.

Property Summary

  • _decimalInfo
  • constraintsDespite the name, this parameter specifies both constraints on the input (including minimum/maximum allowed values) as well as formatting options like places (the number of digits to display after the decimal point).
  • editOptionsProperties to mix into constraints when the value is being edited.
  • valueThe value of this NumberTextBox as a Javascript Number (i.e., not a String).

Method Summary

  • _formatter(value,options) Format a Number as a String, using locale-specific settings
  • _getDisplayedValueAttr()
  • _getValueAttr() Hook so get('value') works.
  • _isValidSubset()
  • _parser(expression,options) Convert a properly formatted string to a primitive Number, using locale-specific settings.
  • _regExpGenerator(options) Builds the regular needed to parse a number
  • _setBlurValue()
  • _setConstraintsAttr(constraints)
  • _setValueAttr(value,priorityChange,formattedValue) Hook so set('value', ...) works.
  • filter(value) This is called with both the display value (string), and the actual value (a number).
  • format(value,constraints) Formats the value as a Number, according to constraints.
  • isValid(isFocused)
  • parse(value,constraints) Replaceable function to convert a formatted string to a number value
  • pattern(constraints)
  • postMixInProperties()
  • serialize(value,options) Convert value (a Number) into a canonical string (ie, how the number literal is written in javascript/java/C/etc.)

Event Summary

Properties

_decimalInfo
constraints

Despite the name, this parameter specifies both constraints on the input (including minimum/maximum allowed values) as well as formatting options like places (the number of digits to display after the decimal point).

editOptions

Properties to mix into constraints when the value is being edited. This is here because we edit the number in the format "12345", which is different than the display value (ex: "12,345")

value

The value of this NumberTextBox as a Javascript Number (i.e., not a String). If the displayed value is blank, the value is NaN, and if the user types in an gibberish value (like "hello world"), the value is undefined (i.e. get('value') returns undefined).

Symmetrically, set('value', NaN) will clear the displayed value, whereas set('value', undefined) will have no effect.

Methods

_formatter(value,options)

Format a Number as a String, using locale-specific settings

Create a string from a Number using a known localized pattern. Formatting patterns appropriate to the locale are chosen from the Common Locale Data Repository as well as the appropriate symbols and delimiters. If value is Infinity, -Infinity, or is not a valid JavaScript number, return null.

Parameter Type Description
value Number

the number to be formatted

options Object
Optional

An object with the following properties:

  • pattern (String, optional):

    override formatting pattern with this string. Default value is based on locale. Overriding this property will defeat localization. Literal characters in patterns are not supported.

  • type (String, optional):

    choose a format type based on the locale from the following: decimal, scientific (not yet supported), percent, currency. decimal by default.

  • places (Number, optional):

    fixed number of decimal places to show. This overrides any information in the provided pattern.

  • round (Number, optional):

    5 rounds to nearest .5; 0 rounds to nearest whole (default). -1 means do not round.

  • locale (String, optional):

    override the locale used to determine formatting rules

  • fractional (Boolean, optional):

    If false, show no decimal places, overriding places and pattern settings.

Returns:null | undefined
_getDisplayedValueAttr()
Returns:undefined
_getValueAttr()

Hook so get('value') works. Returns Number, NaN for '', or undefined for unparseable text

Returns:undefined
_isValidSubset()
Returns:undefined | boolean
_parser(expression,options)

Convert a properly formatted string to a primitive Number, using locale-specific settings.

Create a Number from a string using a known localized pattern. Formatting patterns are chosen appropriate to the locale and follow the syntax described by unicode.org TR35 Note that literal characters in patterns are not supported.

Parameter Type Description
expression String

A string representation of a Number

options Object
Optional

An object with the following properties:

  • pattern (String, optional):

    override formatting pattern with this string. Default value is based on locale. Overriding this property will defeat localization. Literal characters in patterns are not supported.

  • type (String, optional):

    choose a format type based on the locale from the following: decimal, scientific (not yet supported), percent, currency. decimal by default.

  • locale (String, optional):

    override the locale used to determine formatting rules

  • strict (Boolean, optional):

    strict parsing, false by default. Strict parsing requires input as produced by the format() method. Non-strict is more permissive, e.g. flexible on white space, omitting thousands separators

  • fractional (Boolean|Array, optional):

    Whether to include the fractional portion, where the number of decimal places are implied by pattern or explicit 'places' parameter. The value [true,false] makes the fractional portion optional.

Returns:number
_regExpGenerator(options)

Builds the regular needed to parse a number

Returns regular expression with positive and negative match, group and decimal separators

Parameter Type Description
options Object
Optional

An object with the following properties:

  • pattern (String, optional):

    override formatting pattern with this string. Default value is based on locale. Overriding this property will defeat localization.

  • type (String, optional):

    choose a format type based on the locale from the following: decimal, scientific (not yet supported), percent, currency. decimal by default.

  • locale (String, optional):

    override the locale used to determine formatting rules

  • strict (Boolean, optional):

    strict parsing, false by default. Strict parsing requires input as produced by the format() method. Non-strict is more permissive, e.g. flexible on white space, omitting thousands separators

  • places (Number|String, optional):

    number of decimal places to accept: Infinity, a positive number, or a range "n,m". Defined by pattern or Infinity if pattern not provided.

Returns:undefined
_setBlurValue()
_setConstraintsAttr(constraints)
Parameter Type Description
constraints Object
_setValueAttr(value,priorityChange,formattedValue)

Hook so set('value', ...) works.

Parameter Type Description
value Number
priorityChange Boolean
Optional
formattedValue String
Optional
filter(value)

This is called with both the display value (string), and the actual value (a number). When called with the actual value it does corrections so that '' etc. are represented as NaN. Otherwise it dispatches to the superclass's filter() method.

See dijit/form/TextBox.filter() for more details.

Parameter Type Description
value Number
Returns:number | undefined
format(value,constraints)

Formats the value as a Number, according to constraints.

Parameter Type Description
value Number
constraints Object

An object with the following properties:

  • pattern (String, optional):

    override formatting pattern with this string. Default value is based on locale. Overriding this property will defeat localization. Literal characters in patterns are not supported.

  • type (String, optional):

    choose a format type based on the locale from the following: decimal, scientific (not yet supported), percent, currency. decimal by default.

  • places (Number, optional):

    fixed number of decimal places to show. This overrides any information in the provided pattern.

  • round (Number, optional):

    5 rounds to nearest .5; 0 rounds to nearest whole (default). -1 means do not round.

  • locale (String, optional):

    override the locale used to determine formatting rules

  • fractional (Boolean, optional):

    If false, show no decimal places, overriding places and pattern settings.

Returns:undefined | string
isValid(isFocused)
Parameter Type Description
isFocused Boolean
Returns:undefined | boolean
parse(value,constraints)

Replaceable function to convert a formatted string to a number value

Parameter Type Description
value String
constraints Object

An object with the following properties:

  • pattern (String, optional):

    override formatting pattern with this string. Default value is based on locale. Overriding this property will defeat localization. Literal characters in patterns are not supported.

  • type (String, optional):

    choose a format type based on the locale from the following: decimal, scientific (not yet supported), percent, currency. decimal by default.

  • places (Number, optional):

    fixed number of decimal places to show. This overrides any information in the provided pattern.

  • round (Number, optional):

    5 rounds to nearest .5; 0 rounds to nearest whole (default). -1 means do not round.

  • locale (String, optional):

    override the locale used to determine formatting rules

  • fractional (Boolean, optional):

    If false, show no decimal places, overriding places and pattern settings.

Returns:undefined
pattern(constraints)
Parameter Type Description
constraints undefined
Returns:string
postMixInProperties()
serialize(value,options)

Convert value (a Number) into a canonical string (ie, how the number literal is written in javascript/java/C/etc.)

Parameter Type Description
value Number
options Object
Optional
Returns:string

Events

_onFocus()
Error in the documentation? Can’t find what you are looking for? Let us know!