Ext JS 3.4.0 Sencha Docs

Ext.util.Format

Files

Reusable data formatting functions

Available since: 1.1.0

Defined By

Methods

Ext.util.Format
view source
( value ) : String
Converts the first character only of a string to upper case ...

Converts the first character only of a string to upper case

Available since: 1.1.0

Parameters

  • value : String

    The text to convert

Returns

Ext.util.Format
view source
( value, [format] ) : String
Parse a value into a formatted date using the specified format pattern. ...

Parse a value into a formatted date using the specified format pattern.

Available since: 1.1.0

Parameters

  • value : String/Date

    The value to format (Strings must conform to the format expected by the javascript Date object's parse() method)

  • format : String (optional)

    Any valid date format string (defaults to 'm/d/Y')

Returns

  • String

    The formatted date string

Ext.util.Format
view source
( format ) : Function
Returns a date rendering function that can be reused to apply a date format multiple times efficiently ...

Returns a date rendering function that can be reused to apply a date format multiple times efficiently

Available since: 1.1.0

Parameters

  • format : String

    Any valid date format string

Returns

Ext.util.Format
view source
( value, defaultValue ) : String
Checks a reference and converts it to the default value if it's empty ...

Checks a reference and converts it to the default value if it's empty

Available since: 2.3.0

Parameters

  • value : Mixed

    Reference to check

  • defaultValue : String

    The value to insert if it's undefined (defaults to "")

Returns

Ext.util.Format
view source
( value, length, word ) : String
Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length ...

Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length

Available since: 1.1.0

Parameters

  • value : String

    The string to truncate

  • length : Number

    The maximum length to allow before truncating

  • word : Boolean

    True to try to find a common work break

Returns

Ext.util.Format
view source
( size ) : String
Simple format for a file size (xxx bytes, xxx KB, xxx MB) ...

Simple format for a file size (xxx bytes, xxx KB, xxx MB)

Available since: 2.3.0

Parameters

Returns

  • String

    The formatted file size

Ext.util.Format
view source
( value ) : String
Convert certain characters (&, <, >, and ') from their HTML character equivalents. ...

Convert certain characters (&, <, >, and ') from their HTML character equivalents.

Available since: 1.1.0

Parameters

  • value : String

    The string to decode

Returns

Ext.util.Format
view source
( value ) : String
Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. ...

Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.

Available since: 1.1.0

Parameters

  • value : String

    The string to encode

Returns

Ext.util.Format
view source
( value ) : String
Converts a string to all lower case letters ...

Converts a string to all lower case letters

Available since: 1.1.0

Parameters

  • value : String

    The text to convert

Returns

Ext.util.Format
view source
( ) : Function
It does simple math for use in a template, for example: var tpl = new Ext.Template('{value} * 10 = {value:math("* 10...

It does simple math for use in a template, for example:

var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")}');

Available since: Ext JS 3.4.0

Returns

  • Function

    A function that operates on the passed value.

Ext.util.Format
view source
( The ) : String
Converts newline characters to the HTML tag <br/> ...

Converts newline characters to the HTML tag <br/>

Available since: 2.3.0

Parameters

  • The : String

    string value to format.

Returns

  • String

    The string with embedded <br/> tags in place of newlines.

Ext.util.Format
view source
( v, format ) : String
Formats the number according to the format string. ...

Formats the number according to the format string.

examples (123456.789):
0 - (123456) show only digits, no precision
0.00 - (123456.78) show only digits, 2 precision
0.0000 - (123456.7890) show only digits, 4 precision
0,000 - (123,456) show comma and digits, no precision
0,000.00 - (123,456.78) show comma and digits, 2 precision
0,0.00 - (123,456.78) shortcut method, show comma and digits, 2 precision
To reverse the grouping (,) and decimal (.) for international numbers, add /i to the end. For example: 0.000,00/i

Available since: Ext JS 3.4.0

Parameters

  • v : Number

    The number to format.

  • format : String

    The way you would like to format this text.

Returns

Ext.util.Format
view source
( format ) : Function
Returns a number rendering function that can be reused to apply a number format multiple times efficiently ...

Returns a number rendering function that can be reused to apply a number format multiple times efficiently

Available since: Ext JS 3.4.0

Parameters

Returns

Ext.util.Format
view source
( value, singular, [plural] )
Selectively do a plural form of a word based on a numeric value. ...

Selectively do a plural form of a word based on a numeric value. For example, in a template, {commentCount:plural("Comment")} would result in "1 Comment" if commentCount was 1 or would be "x Comments" if the value is 0 or greater than 1.

Available since: Ext JS 3.4.0

Parameters

  • value : Number

    The value to compare against

  • singular : String

    The singular form of the word

  • plural : String (optional)

    The plural form of the word (defaults to the singular with an "s")

Ext.util.Format
view source
( value, precision ) : Number
Rounds the passed number to the required decimal precision. ...

Rounds the passed number to the required decimal precision.

Available since: Ext JS 3.4.0

Parameters

  • value : Number/String

    The numeric value to round.

  • precision : Number

    The number of decimal places to which to round the first parameter's value.

Returns

Ext.util.Format
view source
( value ) : String
Strips all script tags ...

Strips all script tags

Available since: 2.3.0

Parameters

  • value : Mixed

    The text from which to strip script tags

Returns

Ext.util.Format
view source
( value ) : String
Strips all HTML tags ...

Strips all HTML tags

Available since: 1.1.0

Parameters

  • value : Mixed

    The text from which to strip tags

Returns

Ext.util.Format
view source
( value, start, length ) : String
Returns a substring from within an original string ...

Returns a substring from within an original string

Available since: 1.1.0

Parameters

  • value : String

    The original text

  • start : Number

    The start index of the substring

  • length : Number

    The length of the substring

Returns

Ext.util.Format
view source
( value ) : String
Trims any whitespace from either side of a string ...

Trims any whitespace from either side of a string

Available since: 1.1.0

Parameters

  • value : String

    The text to trim

Returns

Ext.util.Format
view source
( value ) : Mixed
Checks a reference and converts it to empty string if it is undefined ...

Checks a reference and converts it to empty string if it is undefined

Available since: 1.1.0

Parameters

  • value : Mixed

    Reference to check

Returns

  • Mixed

    Empty string if converted, otherwise the original value

Ext.util.Format
view source
( value ) : String
Converts a string to all upper case letters ...

Converts a string to all upper case letters

Available since: 1.1.0

Parameters

  • value : String

    The text to convert

Returns

Ext.util.Format
view source
( value ) : String
Format a number as US currency ...

Format a number as US currency

Available since: 1.1.0

Parameters

Returns

  • String

    The formatted currency string