-<div xmlns:ext="http://www.extjs.com" class="body-wrap"><h1>Class <a href="source/Format.html#cls-Ext.util.Format">Ext.util.Format</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.util</td></tr><tr><td class="label">Defined In:</td><td class="hd-info">Format.js</td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/Format.html#cls-Ext.util.Format">Format</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr></table><div class="description">Reusable data formatting functions<br><br><i>This class is a singleton and cannot be created directly.</i></div><div class="hr"></div><a id="Ext.util.Format-props"></a><h2>Public Properties</h2><div class="no-members">This class has no public properties.</div><a id="Ext.util.Format-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-capitalize"></a><b><a href="source/Format.html#method-Ext.util.Format-capitalize">capitalize</a></b>( <code>String value</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Converts the first character only of a string to upper case</div><div class="long">Converts the first character only of a string to upper case<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The text to convert</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-date"></a><b><a href="source/Format.html#method-Ext.util.Format-date">date</a></b>( <code>String/Date value</code>, <span title="Optional" class="optional">[<code>String format</code>]</span> )\r
- :\r
- String<div class="mdesc"><div class="short">Parse a value into a formatted date using the specified format pattern.</div><div class="long">Parse a value into a formatted date using the specified format pattern.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String/Date<div class="sub-desc">The value to format (Strings must conform to the format expected by the javascript Date object's <a href="http://www.w3schools.com/jsref/jsref_parse.asp">parse()</a> method)</div></li><li><code>format</code> : String<div class="sub-desc">(optional) Any valid date format string (defaults to 'm/d/Y')</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The formatted date string</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-dateRenderer"></a><b><a href="source/Format.html#method-Ext.util.Format-dateRenderer">dateRenderer</a></b>( <code>String format</code> )\r
- :\r
- Function<div class="mdesc"><div class="short">Returns a date rendering function that can be reused to apply a date format multiple times efficiently</div><div class="long">Returns a date rendering function that can be reused to apply a date format multiple times efficiently<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>format</code> : String<div class="sub-desc">Any valid date format string</div></li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">The date formatting function</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-defaultValue"></a><b><a href="source/Format.html#method-Ext.util.Format-defaultValue">defaultValue</a></b>( <code>Mixed value</code>, <code>String defaultValue</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Checks a reference and converts it to the default value if it's empty</div><div class="long">Checks a reference and converts it to the default value if it's empty<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : Mixed<div class="sub-desc">Reference to check</div></li><li><code>defaultValue</code> : String<div class="sub-desc">The value to insert of it's undefined (defaults to "")</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-ellipsis"></a><b><a href="source/Format.html#method-Ext.util.Format-ellipsis">ellipsis</a></b>( <code>String value</code>, <code>Number length</code>, <code>Boolean word</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length</div><div class="long">Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to truncate</div></li><li><code>length</code> : Number<div class="sub-desc">The maximum length to allow before truncating</div></li><li><code>word</code> : Boolean<div class="sub-desc">True to try to find a common work break</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-fileSize"></a><b><a href="source/Format.html#method-Ext.util.Format-fileSize">fileSize</a></b>( <code>Number/String size</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Simple format for a file size (xxx bytes, xxx KB, xxx MB)</div><div class="long">Simple format for a file size (xxx bytes, xxx KB, xxx MB)<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>size</code> : Number/String<div class="sub-desc">The numeric value to format</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The formatted file size</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-htmlDecode"></a><b><a href="source/Format.html#method-Ext.util.Format-htmlDecode">htmlDecode</a></b>( <code>String value</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Convert certain characters (&, <, >, and ') from their HTML character equivalents.</div><div class="long">Convert certain characters (&, <, >, and ') from their HTML character equivalents.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to decode</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The decoded text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-htmlEncode"></a><b><a href="source/Format.html#method-Ext.util.Format-htmlEncode">htmlEncode</a></b>( <code>String value</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.</div><div class="long">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to encode</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The encoded text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-lowercase"></a><b><a href="source/Format.html#method-Ext.util.Format-lowercase">lowercase</a></b>( <code>String value</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Converts a string to all lower case letters</div><div class="long">Converts a string to all lower case letters<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The text to convert</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-math"></a><b><a href="source/Format.html#method-Ext.util.Format-math">math</a></b>()\r
- :\r
- Function<div class="mdesc"><div class="short">It does simple math for use in a template, for example:var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")...</div><div class="long">It does simple math for use in a template, for example:<pre><code><b>var</b> tpl = <b>new</b> Ext.Template(<em>'{value} * 10 = {value:math(<em>"* 10"</em>)}'</em>);</code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li>None.</li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">A function that operates on the passed value.</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-nl2br"></a><b><a href="source/Format.html#method-Ext.util.Format-nl2br">nl2br</a></b>( <code>String The</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Converts newline characters to the HTML tag &lt;br/></div><div class="long">Converts newline characters to the HTML tag <br/><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>The</code> : String<div class="sub-desc">string value to format.</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The string with embedded &lt;br/> tags in place of newlines.</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-number"></a><b><a href="source/Format.html#method-Ext.util.Format-number">number</a></b>( <code>Number v</code>, <code>String format</code> )\r
- :\r
- String<div class="mdesc"><div class="short">Formats the number according to the format string. \r
-<div style="margin-left:40px">examples (123456.789): \r
+<div xmlns:ext="http://www.extjs.com" class="body-wrap"><h1>Class <a href="source/Format.html#cls-Ext.util.Format">Ext.util.Format</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.util</td></tr><tr><td class="label">Defined In:</td><td class="hd-info">Format.js</td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/Format.html#cls-Ext.util.Format">Format</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr></table><div class="description">Reusable data formatting functions<br><br><i>This class is a singleton and cannot be created directly.</i></div><div class="hr"></div><a id="Ext.util.Format-props"></a><h2>Public Properties</h2><div class="no-members">This class has no public properties.</div><a id="Ext.util.Format-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-capitalize"></a><b><a href="source/Format.html#method-Ext.util.Format-capitalize">capitalize</a></b>( <code>String value</code> )
+ :
+ String<div class="mdesc"><div class="short">Converts the first character only of a string to upper case</div><div class="long">Converts the first character only of a string to upper case<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The text to convert</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-date"></a><b><a href="source/Format.html#method-Ext.util.Format-date">date</a></b>( <code>String/Date value</code>, <span title="Optional" class="optional">[<code>String format</code>]</span> )
+ :
+ String<div class="mdesc"><div class="short">Parse a value into a formatted date using the specified format pattern.</div><div class="long">Parse a value into a formatted date using the specified format pattern.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String/Date<div class="sub-desc">The value to format (Strings must conform to the format expected by the javascript Date object's <a href="http://www.w3schools.com/jsref/jsref_parse.asp">parse()</a> method)</div></li><li><code>format</code> : String<div class="sub-desc">(optional) Any valid date format string (defaults to 'm/d/Y')</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The formatted date string</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-dateRenderer"></a><b><a href="source/Format.html#method-Ext.util.Format-dateRenderer">dateRenderer</a></b>( <code>String format</code> )
+ :
+ Function<div class="mdesc"><div class="short">Returns a date rendering function that can be reused to apply a date format multiple times efficiently</div><div class="long">Returns a date rendering function that can be reused to apply a date format multiple times efficiently<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>format</code> : String<div class="sub-desc">Any valid date format string</div></li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">The date formatting function</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-defaultValue"></a><b><a href="source/Format.html#method-Ext.util.Format-defaultValue">defaultValue</a></b>( <code>Mixed value</code>, <code>String defaultValue</code> )
+ :
+ String<div class="mdesc"><div class="short">Checks a reference and converts it to the default value if it's empty</div><div class="long">Checks a reference and converts it to the default value if it's empty<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : Mixed<div class="sub-desc">Reference to check</div></li><li><code>defaultValue</code> : String<div class="sub-desc">The value to insert of it's undefined (defaults to "")</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc"></div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-ellipsis"></a><b><a href="source/Format.html#method-Ext.util.Format-ellipsis">ellipsis</a></b>( <code>String value</code>, <code>Number length</code>, <code>Boolean word</code> )
+ :
+ String<div class="mdesc"><div class="short">Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length</div><div class="long">Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to truncate</div></li><li><code>length</code> : Number<div class="sub-desc">The maximum length to allow before truncating</div></li><li><code>word</code> : Boolean<div class="sub-desc">True to try to find a common work break</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-fileSize"></a><b><a href="source/Format.html#method-Ext.util.Format-fileSize">fileSize</a></b>( <code>Number/String size</code> )
+ :
+ String<div class="mdesc"><div class="short">Simple format for a file size (xxx bytes, xxx KB, xxx MB)</div><div class="long">Simple format for a file size (xxx bytes, xxx KB, xxx MB)<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>size</code> : Number/String<div class="sub-desc">The numeric value to format</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The formatted file size</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-htmlDecode"></a><b><a href="source/Format.html#method-Ext.util.Format-htmlDecode">htmlDecode</a></b>( <code>String value</code> )
+ :
+ String<div class="mdesc"><div class="short">Convert certain characters (&, <, >, and ') from their HTML character equivalents.</div><div class="long">Convert certain characters (&, <, >, and ') from their HTML character equivalents.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to decode</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The decoded text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-htmlEncode"></a><b><a href="source/Format.html#method-Ext.util.Format-htmlEncode">htmlEncode</a></b>( <code>String value</code> )
+ :
+ String<div class="mdesc"><div class="short">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.</div><div class="long">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The string to encode</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The encoded text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-lowercase"></a><b><a href="source/Format.html#method-Ext.util.Format-lowercase">lowercase</a></b>( <code>String value</code> )
+ :
+ String<div class="mdesc"><div class="short">Converts a string to all lower case letters</div><div class="long">Converts a string to all lower case letters<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The text to convert</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The converted text</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-math"></a><b><a href="source/Format.html#method-Ext.util.Format-math">math</a></b>()
+ :
+ Function<div class="mdesc"><div class="short">It does simple math for use in a template, for example:var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")...</div><div class="long">It does simple math for use in a template, for example:<pre><code><b>var</b> tpl = <b>new</b> Ext.Template(<em>'{value} * 10 = {value:math(<em>"* 10"</em>)}'</em>);</code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li>None.</li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">A function that operates on the passed value.</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-nl2br"></a><b><a href="source/Format.html#method-Ext.util.Format-nl2br">nl2br</a></b>( <code>String The</code> )
+ :
+ String<div class="mdesc"><div class="short">Converts newline characters to the HTML tag &lt;br/></div><div class="long">Converts newline characters to the HTML tag <br/><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>The</code> : String<div class="sub-desc">string value to format.</div></li></ul><strong>Returns:</strong><ul><li><code>String</code><div class="sub-desc">The string with embedded &lt;br/> tags in place of newlines.</div></li></ul></div></div></div></td><td class="msource">Format</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Format-number"></a><b><a href="source/Format.html#method-Ext.util.Format-number">number</a></b>( <code>Number v</code>, <code>String format</code> )
+ :
+ String<div class="mdesc"><div class="short">Formats the number according to the format string.
+<div style="margin-left:40px">examples (123456.789):