1 <!DOCTYPE html><html><head><title>Ext.util.Format | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
12 origDocClass: 'Ext.util.Format',
13 docClass: 'Ext.util.Format',
14 docReq: 'Ext.util.Format',
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32 req.source = 'Format.html#Ext-util.Format';
33 clsInfo = {"methods":["currency","date","dateRenderer","defaultValue","escapeRegex","fileSize","lowercase","math","nl2br","number","numberRenderer","parseBox","plural","round","stripScripts","stripTags","substr","undef","uppercase","usMoney"],"cfgs":[],"properties":["capitalize","currencyAtEnd","currencyPrecision","currencySign","decimalSeparator","ellipsis","format","htmlDecode","htmlEncode","leftPad","thousandSeparator","trim"],"events":[],"subclasses":[]};
34 Ext.onReady(function() {
35 Ext.create('Docs.classPanel');
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Format.html#Ext-util.Format" target="_blank">Ext.util.Format</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>This class is a centralized place for formatting functions inside the library. It includes
38 functions to format various different types of data, such as text, dates and numeric values.</p>
40 <p><strong>Localization</strong>
41 This class contains several options for localization. These can be set once the library has loaded,
42 all calls to the functions from that point will use the locale settings that were specified.
49 This class also uses the default date format defined here: <a href="Ext.date.html#defaultFormat" rel="Ext.date#defaultFormat" class="docClass">Ext.date.defaultFormat</a>.</p>
51 <p><strong>Using with renderers</strong>
52 There are two helper functions that return a new function that can be used in conjunction with
55 <pre class="prettyprint"><code>columns: [{
57 renderer: Ext.util.Format.dateRenderer('Y-m-d')
60 renderer: Ext.util.Format.numberRenderer('0.000')
64 <p>Functions that only take a single argument can also be passed directly:</p>
66 <pre class="prettyprint"><code>columns: [{
68 renderer: Ext.util.Format.usMoney
70 dataIndex: 'productCode',
71 renderer: Ext.util.Format.uppercase
75 <p><strong>Using with XTemplates</strong>
76 XTemplates can also directly use <a href="Ext.util.Format.html" rel="Ext.util.Format" class="docClass">Ext.util.Format</a> functions:</p>
78 <pre class="prettyprint"><code>new Ext.XTemplate([
79 'Date: {startDate:date("Y-m-d")}',
80 'Cost: {cost:usMoney}'
83 <div class="members"><div class="m-properties"><a name="properties"></a><div class="definedBy">Defined By</div><h3 class="prp p">Properties</h3><div id="property-capitalize" class="member f ni"><a href="Ext.util.Format.html#property-capitalize" rel="property-capitalize" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-capitalize" class="viewSource">view source</a></div><a name="capitalize"></a><a name="property-capitalize"></a><a href="Ext.util.Format.html#" rel="property-capitalize" class="cls expand">capitalize</a><span> : Object</span></div><div class="description"><div class="short"><p>Capitalize the given string. See <a href="Ext.String.html#capitalize" rel="Ext.String#capitalize" class="docClass">Ext.String.capitalize</a>.</p>
84 </div><div class="long"><p>Capitalize the given string. See <a href="Ext.String.html#capitalize" rel="Ext.String#capitalize" class="docClass">Ext.String.capitalize</a>.</p>
85 </div></div></div><div id="property-currencyAtEnd" class="member ni"><a href="Ext.util.Format.html#property-currencyAtEnd" rel="property-currencyAtEnd" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-currencyAtEnd" class="viewSource">view source</a></div><a name="currencyAtEnd"></a><a name="property-currencyAtEnd"></a><a href="Ext.util.Format.html#" rel="property-currencyAtEnd" class="cls expand">currencyAtEnd</a><span> : Boolean</span></div><div class="description"><div class="short">This may be set to true to make the currency function
86 append the currency sign to the formatted value.
89 This default...</div><div class="long"><p>This may be set to <code>true</code> to make the <a href="Ext.util.Format.html#currency" rel="Ext.util.Format#currency" class="docClass">currency</a> function
90 append the currency sign to the formatted value.</p>
93 <p>This defaults to <code>false</code>, but may be overridden in a locale file.</p>
95 </div></div></div><div id="property-currencyPrecision" class="member ni"><a href="Ext.util.Format.html#property-currencyPrecision" rel="property-currencyPrecision" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-currencyPrecision" class="viewSource">view source</a></div><a name="currencyPrecision"></a><a name="property-currencyPrecision"></a><a href="Ext.util.Format.html#" rel="property-currencyPrecision" class="cls expand">currencyPrecision</a><span> : Number</span></div><div class="description"><div class="short">The number of decimal places that the currency function displays.
98 This defaults to 2, but may be overridden in a lo...</div><div class="long"><p>The number of decimal places that the <a href="Ext.util.Format.html#currency" rel="Ext.util.Format#currency" class="docClass">currency</a> function displays.</p>
101 <p>This defaults to <code>2</code>, but may be overridden in a locale file.</p>
103 </div></div></div><div id="property-currencySign" class="member ni"><a href="Ext.util.Format.html#property-currencySign" rel="property-currencySign" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-currencySign" class="viewSource">view source</a></div><a name="currencySign"></a><a name="property-currencySign"></a><a href="Ext.util.Format.html#" rel="property-currencySign" class="cls expand">currencySign</a><span> : String</span></div><div class="description"><div class="short"><p>The currency sign that the <a href="Ext.util.Format.html#currency" rel="Ext.util.Format#currency" class="docClass">currency</a> function displays.</p>
106 <p>This defaults to <code>$</code>, but may be overridden in a locale file.</p>
108 </div><div class="long"><p>The currency sign that the <a href="Ext.util.Format.html#currency" rel="Ext.util.Format#currency" class="docClass">currency</a> function displays.</p>
111 <p>This defaults to <code>$</code>, but may be overridden in a locale file.</p>
113 </div></div></div><div id="property-decimalSeparator" class="member ni"><a href="Ext.util.Format.html#property-decimalSeparator" rel="property-decimalSeparator" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-decimalSeparator" class="viewSource">view source</a></div><a name="decimalSeparator"></a><a name="property-decimalSeparator"></a><a href="Ext.util.Format.html#" rel="property-decimalSeparator" class="cls expand">decimalSeparator</a><span> : String</span></div><div class="description"><div class="short">The character that the number function uses as a decimal point.
116 This defaults to ., but may be overridden in a loca...</div><div class="long"><p>The character that the <a href="Ext.util.Format.html#number" rel="Ext.util.Format#number" class="docClass">number</a> function uses as a decimal point.</p>
119 <p>This defaults to <code>.</code>, but may be overridden in a locale file.</p>
121 </div></div></div><div id="property-ellipsis" class="member ni"><a href="Ext.util.Format.html#property-ellipsis" rel="property-ellipsis" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-ellipsis" class="viewSource">view source</a></div><a name="ellipsis"></a><a name="property-ellipsis"></a><a href="Ext.util.Format.html#" rel="property-ellipsis" class="cls expand">ellipsis</a><span> : Object</span></div><div class="description"><div class="short"><p>Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length.
122 See <a href="Ext.String.html#ellipsis" rel="Ext.String#ellipsis" class="docClass">Ext.String.ellipsis</a>.</p>
123 </div><div class="long"><p>Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length.
124 See <a href="Ext.String.html#ellipsis" rel="Ext.String#ellipsis" class="docClass">Ext.String.ellipsis</a>.</p>
125 </div></div></div><div id="property-format" class="member ni"><a href="Ext.util.Format.html#property-format" rel="property-format" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-format" class="viewSource">view source</a></div><a name="format"></a><a name="property-format"></a><a href="Ext.util.Format.html#" rel="property-format" class="cls expand">format</a><span> : Object</span></div><div class="description"><div class="short"><p>Formats to a string. See <a href="Ext.String.html#format" rel="Ext.String#format" class="docClass">Ext.String.format</a></p>
126 </div><div class="long"><p>Formats to a string. See <a href="Ext.String.html#format" rel="Ext.String#format" class="docClass">Ext.String.format</a></p>
127 </div></div></div><div id="property-htmlDecode" class="member ni"><a href="Ext.util.Format.html#property-htmlDecode" rel="property-htmlDecode" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-htmlDecode" class="viewSource">view source</a></div><a name="htmlDecode"></a><a name="property-htmlDecode"></a><a href="Ext.util.Format.html#" rel="property-htmlDecode" class="cls expand">htmlDecode</a><span> : Object</span></div><div class="description"><div class="short"><p>Convert certain characters (&, <, >, and ') from their HTML character equivalents.
128 See <a href="Ext.string.html#htmlDecode" rel="Ext.string#htmlDecode" class="docClass">Ext.string.htmlDecode</a>.</p>
129 </div><div class="long"><p>Convert certain characters (&, <, >, and ') from their HTML character equivalents.
130 See <a href="Ext.string.html#htmlDecode" rel="Ext.string#htmlDecode" class="docClass">Ext.string.htmlDecode</a>.</p>
131 </div></div></div><div id="property-htmlEncode" class="member ni"><a href="Ext.util.Format.html#property-htmlEncode" rel="property-htmlEncode" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-htmlEncode" class="viewSource">view source</a></div><a name="htmlEncode"></a><a name="property-htmlEncode"></a><a href="Ext.util.Format.html#" rel="property-htmlEncode" class="cls expand">htmlEncode</a><span> : Object</span></div><div class="description"><div class="short">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pag...</div><div class="long"><p>Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
132 See <a href="Ext.String.html#htmlEncode" rel="Ext.String#htmlEncode" class="docClass">Ext.String.htmlEncode</a>.</p>
133 </div></div></div><div id="property-leftPad" class="member ni"><a href="Ext.util.Format.html#property-leftPad" rel="property-leftPad" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-leftPad" class="viewSource">view source</a></div><a name="leftPad"></a><a name="property-leftPad"></a><a href="Ext.util.Format.html#" rel="property-leftPad" class="cls expand">leftPad</a><span> : Object</span></div><div class="description"><div class="short"><p>Adds left padding to a string. See <a href="Ext.String.html#leftPad" rel="Ext.String#leftPad" class="docClass">Ext.String.leftPad</a></p>
134 </div><div class="long"><p>Adds left padding to a string. See <a href="Ext.String.html#leftPad" rel="Ext.String#leftPad" class="docClass">Ext.String.leftPad</a></p>
135 </div></div></div><div id="property-thousandSeparator" class="member ni"><a href="Ext.util.Format.html#property-thousandSeparator" rel="property-thousandSeparator" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-thousandSeparator" class="viewSource">view source</a></div><a name="thousandSeparator"></a><a name="property-thousandSeparator"></a><a href="Ext.util.Format.html#" rel="property-thousandSeparator" class="cls expand">thousandSeparator</a><span> : String</span></div><div class="description"><div class="short">The character that the number function uses as a thousand separator.
138 This defaults to ,, but may be overridden in a...</div><div class="long"><p>The character that the <a href="Ext.util.Format.html#number" rel="Ext.util.Format#number" class="docClass">number</a> function uses as a thousand separator.</p>
141 <p>This defaults to <code>,</code>, but may be overridden in a locale file.</p>
143 </div></div></div><div id="property-trim" class="member ni"><a href="Ext.util.Format.html#property-trim" rel="property-trim" class="expand more"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-property-trim" class="viewSource">view source</a></div><a name="trim"></a><a name="property-trim"></a><a href="Ext.util.Format.html#" rel="property-trim" class="cls expand">trim</a><span> : Object</span></div><div class="description"><div class="short"><p>Trims any whitespace from either side of a string. See <a href="Ext.String.html#trim" rel="Ext.String#trim" class="docClass">Ext.String.trim</a>.</p>
144 </div><div class="long"><p>Trims any whitespace from either side of a string. See <a href="Ext.String.html#trim" rel="Ext.String#trim" class="docClass">Ext.String.trim</a>.</p>
145 </div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-currency" class="member f ni"><a href="Ext.util.Format.html#method-currency" rel="method-currency" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-currency" class="viewSource">view source</a></div><a name="currency"></a><a name="method-currency"></a><a href="Ext.util.Format.html#" rel="method-currency" class="cls expand">currency</a>(
146 <span class="pre">Number/String value, String sign, Number decimals, Boolean end</span>)
147 : String</div><div class="description"><div class="short"><p>Format a number as a currency</p>
148 </div><div class="long"><p>Format a number as a currency</p>
149 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number/String<div class="sub-desc"><p>The numeric value to format</p>
150 </div></li><li><span class="pre">sign</span> : String<div class="sub-desc"><p>The currency sign to use (defaults to <a href="Ext.util.Format.html#currencySign" rel="Ext.util.Format#currencySign" class="docClass">currencySign</a>)</p>
151 </div></li><li><span class="pre">decimals</span> : Number<div class="sub-desc"><p>The number of decimals to use for the currency (defaults to <a href="Ext.util.Format.html#currencyPrecision" rel="Ext.util.Format#currencyPrecision" class="docClass">currencyPrecision</a>)</p>
152 </div></li><li><span class="pre">end</span> : Boolean<div class="sub-desc"><p>True if the currency sign should be at the end of the string (defaults to <a href="Ext.util.Format.html#currencyAtEnd" rel="Ext.util.Format#currencyAtEnd" class="docClass">currencyAtEnd</a>)</p>
153 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The formatted currency string</p>
154 </li></ul></div></div></div><div id="method-date" class="member ni"><a href="Ext.util.Format.html#method-date" rel="method-date" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-date" class="viewSource">view source</a></div><a name="date"></a><a name="method-date"></a><a href="Ext.util.Format.html#" rel="method-date" class="cls expand">date</a>(
155 <span class="pre">String/Date value, String format</span>)
156 : String</div><div class="description"><div class="short"><p>Formats the passed date using the specified format pattern.</p>
157 </div><div class="long"><p>Formats the passed date using the specified format pattern.</p>
158 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String/Date<div class="sub-desc"><p>The value to format. If a string is passed, it is converted to a Date by the Javascript
159 Date object's <a href="http://www.w3schools.com/jsref/jsref_parse.asp">parse()</a> method.</p>
160 </div></li><li><span class="pre">format</span> : String<div class="sub-desc"><p>(Optional) Any valid date format string. Defaults to <a href="Ext.Date.html#defaultFormat" rel="Ext.Date#defaultFormat" class="docClass">Ext.Date.defaultFormat</a>.</p>
161 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The formatted date string.</p>
162 </li></ul></div></div></div><div id="method-dateRenderer" class="member ni"><a href="Ext.util.Format.html#method-dateRenderer" rel="method-dateRenderer" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-dateRenderer" class="viewSource">view source</a></div><a name="dateRenderer"></a><a name="method-dateRenderer"></a><a href="Ext.util.Format.html#" rel="method-dateRenderer" class="cls expand">dateRenderer</a>(
163 <span class="pre">String format</span>)
164 : Function</div><div class="description"><div class="short"><p>Returns a date rendering function that can be reused to apply a date format multiple times efficiently</p>
165 </div><div class="long"><p>Returns a date rendering function that can be reused to apply a date format multiple times efficiently</p>
166 <h3 class="pa">Parameters</h3><ul><li><span class="pre">format</span> : String<div class="sub-desc"><p>Any valid date format string. Defaults to <a href="Ext.Date.html#defaultFormat" rel="Ext.Date#defaultFormat" class="docClass">Ext.Date.defaultFormat</a>.</p>
167 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Function</span> <p>The date formatting function</p>
168 </li></ul></div></div></div><div id="method-defaultValue" class="member ni"><a href="Ext.util.Format.html#method-defaultValue" rel="method-defaultValue" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-defaultValue" class="viewSource">view source</a></div><a name="defaultValue"></a><a name="method-defaultValue"></a><a href="Ext.util.Format.html#" rel="method-defaultValue" class="cls expand">defaultValue</a>(
169 <span class="pre">Mixed value, String defaultValue</span>)
170 : String</div><div class="description"><div class="short"><p>Checks a reference and converts it to the default value if it's empty</p>
171 </div><div class="long"><p>Checks a reference and converts it to the default value if it's empty</p>
172 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc"><p>Reference to check</p>
173 </div></li><li><span class="pre">defaultValue</span> : String<div class="sub-desc"><p>The value to insert of it's undefined (defaults to "")</p>
174 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span>
175 </li></ul></div></div></div><div id="method-escapeRegex" class="member ni"><a href="Ext.util.Format.html#method-escapeRegex" rel="method-escapeRegex" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-escapeRegex" class="viewSource">view source</a></div><a name="escapeRegex"></a><a name="method-escapeRegex"></a><a href="Ext.util.Format.html#" rel="method-escapeRegex" class="cls expand">escapeRegex</a>(
176 <span class="pre">String str</span>)
177 : String</div><div class="description"><div class="short"><p>Escapes the passed string for use in a regular expression</p>
178 </div><div class="long"><p>Escapes the passed string for use in a regular expression</p>
179 <h3 class="pa">Parameters</h3><ul><li><span class="pre">str</span> : String<div class="sub-desc">
180 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span>
181 </li></ul></div></div></div><div id="method-fileSize" class="member ni"><a href="Ext.util.Format.html#method-fileSize" rel="method-fileSize" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-fileSize" class="viewSource">view source</a></div><a name="fileSize"></a><a name="method-fileSize"></a><a href="Ext.util.Format.html#" rel="method-fileSize" class="cls expand">fileSize</a>(
182 <span class="pre">Number/String size</span>)
183 : String</div><div class="description"><div class="short"><p>Simple format for a file size (xxx bytes, xxx KB, xxx MB)</p>
184 </div><div class="long"><p>Simple format for a file size (xxx bytes, xxx KB, xxx MB)</p>
185 <h3 class="pa">Parameters</h3><ul><li><span class="pre">size</span> : Number/String<div class="sub-desc"><p>The numeric value to format</p>
186 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The formatted file size</p>
187 </li></ul></div></div></div><div id="method-lowercase" class="member ni"><a href="Ext.util.Format.html#method-lowercase" rel="method-lowercase" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-lowercase" class="viewSource">view source</a></div><a name="lowercase"></a><a name="method-lowercase"></a><a href="Ext.util.Format.html#" rel="method-lowercase" class="cls expand">lowercase</a>(
188 <span class="pre">String value</span>)
189 : String</div><div class="description"><div class="short"><p>Converts a string to all lower case letters</p>
190 </div><div class="long"><p>Converts a string to all lower case letters</p>
191 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The text to convert</p>
192 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The converted text</p>
193 </li></ul></div></div></div><div id="method-math" class="member ni"><a href="Ext.util.Format.html#method-math" rel="method-math" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-math" class="viewSource">view source</a></div><a name="math"></a><a name="method-math"></a><a href="Ext.util.Format.html#" rel="method-math" class="cls expand">math</a> : Function</div><div class="description"><div class="short">It does simple math for use in a template, for example:
195 var tpl = new Ext.Template('{value} * 10 = {value:math("* 10...</div><div class="long"><p>It does simple math for use in a template, for example:</p>
197 <pre><code>var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")}');
200 <h3 class="pa">Returns</h3><ul><li><span class="pre">Function</span> <p>A function that operates on the passed value.</p>
201 </li></ul></div></div></div><div id="method-nl2br" class="member ni"><a href="Ext.util.Format.html#method-nl2br" rel="method-nl2br" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-nl2br" class="viewSource">view source</a></div><a name="nl2br"></a><a name="method-nl2br"></a><a href="Ext.util.Format.html#" rel="method-nl2br" class="cls expand">nl2br</a>(
202 <span class="pre">String The</span>)
203 : String</div><div class="description"><div class="short"><p>Converts newline characters to the HTML tag <br/></p>
204 </div><div class="long"><p>Converts newline characters to the HTML tag <br/></p>
205 <h3 class="pa">Parameters</h3><ul><li><span class="pre">The</span> : String<div class="sub-desc"><p>string value to format.</p>
206 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The string with embedded <br/> tags in place of newlines.</p>
207 </li></ul></div></div></div><div id="method-number" class="member ni"><a href="Ext.util.Format.html#method-number" rel="method-number" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-number" class="viewSource">view source</a></div><a name="number"></a><a name="method-number"></a><a href="Ext.util.Format.html#" rel="method-number" class="cls expand">number</a>(
208 <span class="pre">Number v, String format</span>)
209 : String</div><div class="description"><div class="short">Formats the passed number according to the passed format string.
212 The number of digits after the decimal separator c...</div><div class="long"><p>Formats the passed number according to the passed format string.</p>
215 <p>The number of digits after the decimal separator character specifies the number of
216 decimal places in the resulting string. The <u>local-specific</u> decimal character is used in the result.</p>
219 <p>The <i>presence</i> of a thousand separator character in the format string specifies that
220 the <u>locale-specific</u> thousand separator (if any) is inserted separating thousand groups.</p>
223 <p>By default, "," is expected as the thousand separator, and "." is expected as the decimal separator.</p>
226 <p><b>New to Ext4</b></p>
229 <p>Locale-specific characters are always used in the formatted output when inserting
230 thousand and decimal separators.</p>
233 <p>The format string must specify separator characters according to US/UK conventions ("," as the
234 thousand separator, and "." as the decimal separator)</p>
237 <p>To allow specification of format strings according to local conventions for separator characters, add
238 the string <code>/i</code> to the end of the format string.</p>
241 <div style="margin-left:40px">examples (123456.789):
242 <div style="margin-left:10px">
243 0 - (123456) show only digits, no precision<br>
244 0.00 - (123456.78) show only digits, 2 precision<br>
245 0.0000 - (123456.7890) show only digits, 4 precision<br>
246 0,000 - (123,456) show comma and digits, no precision<br>
247 0,000.00 - (123,456.78) show comma and digits, 2 precision<br>
248 0,0.00 - (123,456.78) shortcut method, show comma and digits, 2 precision<br>
249 To allow specification of the formatting string using UK/US grouping characters (,) and decimal (.) for international numbers, add /i to the end.
250 For example: 0.000,00/i
253 <h3 class="pa">Parameters</h3><ul><li><span class="pre">v</span> : Number<div class="sub-desc"><p>The number to format.</p>
254 </div></li><li><span class="pre">format</span> : String<div class="sub-desc"><p>The way you would like to format this text.</p>
255 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The formatted number.</p>
256 </li></ul></div></div></div><div id="method-numberRenderer" class="member ni"><a href="Ext.util.Format.html#method-numberRenderer" rel="method-numberRenderer" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-numberRenderer" class="viewSource">view source</a></div><a name="numberRenderer"></a><a name="method-numberRenderer"></a><a href="Ext.util.Format.html#" rel="method-numberRenderer" class="cls expand">numberRenderer</a>(
257 <span class="pre">String format</span>)
258 : Function</div><div class="description"><div class="short"><p>Returns a number rendering function that can be reused to apply a number format multiple times efficiently</p>
259 </div><div class="long"><p>Returns a number rendering function that can be reused to apply a number format multiple times efficiently</p>
260 <h3 class="pa">Parameters</h3><ul><li><span class="pre">format</span> : String<div class="sub-desc"><p>Any valid number format string for <a href="Ext.util.Format.html#number" rel="Ext.util.Format#number" class="docClass">number</a></p>
261 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Function</span> <p>The number formatting function</p>
262 </li></ul></div></div></div><div id="method-parseBox" class="member ni"><a href="Ext.util.Format.html#method-parseBox" rel="method-parseBox" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-parseBox" class="viewSource">view source</a></div><a name="parseBox"></a><a name="method-parseBox"></a><a href="Ext.util.Format.html#" rel="method-parseBox" class="cls expand">parseBox</a>(
263 <span class="pre">Number|String v</span>)
264 : Object</div><div class="description"><div class="short">Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
265 (e.g. 10, ...</div><div class="long"><p>Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
266 (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result)</p>
267 <h3 class="pa">Parameters</h3><ul><li><span class="pre">v</span> : Number|String<div class="sub-desc"><p>The encoded margins</p>
268 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Object</span> <p>An object with margin sizes for top, right, bottom and left</p>
269 </li></ul></div></div></div><div id="method-plural" class="member ni"><a href="Ext.util.Format.html#method-plural" rel="method-plural" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-plural" class="viewSource">view source</a></div><a name="plural"></a><a name="method-plural"></a><a href="Ext.util.Format.html#" rel="method-plural" class="cls expand">plural</a>(
270 <span class="pre">Number value, String singular, [String plural]</span>)
271 : void</div><div class="description"><div class="short">Selectively do a plural form of a word based on a numeric value. For example, in a template,
272 {commentCount:plural("Co...</div><div class="long"><p>Selectively do a plural form of a word based on a numeric value. For example, in a template,
273 {commentCount:plural("Comment")} would result in "1 Comment" if commentCount was 1 or would be "x Comments"
274 if the value is 0 or greater than 1.</p>
275 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number<div class="sub-desc"><p>The value to compare against</p>
276 </div></li><li><span class="pre">singular</span> : String<div class="sub-desc"><p>The singular form of the word</p>
277 </div></li><li><span class="pre">plural</span> : String<div class="sub-desc"><p>(optional) The plural form of the word (defaults to the singular with an "s")</p>
278 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>
279 </li></ul></div></div></div><div id="method-round" class="member ni"><a href="Ext.util.Format.html#method-round" rel="method-round" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-round" class="viewSource">view source</a></div><a name="round"></a><a name="method-round"></a><a href="Ext.util.Format.html#" rel="method-round" class="cls expand">round</a>(
280 <span class="pre">Number/String value, Number precision</span>)
281 : Number</div><div class="description"><div class="short"><p>Rounds the passed number to the required decimal precision.</p>
282 </div><div class="long"><p>Rounds the passed number to the required decimal precision.</p>
283 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number/String<div class="sub-desc"><p>The numeric value to round.</p>
284 </div></li><li><span class="pre">precision</span> : Number<div class="sub-desc"><p>The number of decimal places to which to round the first parameter's value.</p>
285 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Number</span> <p>The rounded value.</p>
286 </li></ul></div></div></div><div id="method-stripScripts" class="member ni"><a href="Ext.util.Format.html#method-stripScripts" rel="method-stripScripts" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-stripScripts" class="viewSource">view source</a></div><a name="stripScripts"></a><a name="method-stripScripts"></a><a href="Ext.util.Format.html#" rel="method-stripScripts" class="cls expand">stripScripts</a>(
287 <span class="pre">Mixed value</span>)
288 : String</div><div class="description"><div class="short"><p>Strips all script tags</p>
289 </div><div class="long"><p>Strips all script tags</p>
290 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc"><p>The text from which to strip script tags</p>
291 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The stripped text</p>
292 </li></ul></div></div></div><div id="method-stripTags" class="member ni"><a href="Ext.util.Format.html#method-stripTags" rel="method-stripTags" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-stripTags" class="viewSource">view source</a></div><a name="stripTags"></a><a name="method-stripTags"></a><a href="Ext.util.Format.html#" rel="method-stripTags" class="cls expand">stripTags</a>(
293 <span class="pre">Mixed value</span>)
294 : String</div><div class="description"><div class="short"><p>Strips all HTML tags</p>
295 </div><div class="long"><p>Strips all HTML tags</p>
296 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc"><p>The text from which to strip tags</p>
297 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The stripped text</p>
298 </li></ul></div></div></div><div id="method-substr" class="member ni"><a href="Ext.util.Format.html#method-substr" rel="method-substr" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-substr" class="viewSource">view source</a></div><a name="substr"></a><a name="method-substr"></a><a href="Ext.util.Format.html#" rel="method-substr" class="cls expand">substr</a>(
299 <span class="pre">String value, Number start, Number length</span>)
300 : String</div><div class="description"><div class="short"><p>Returns a substring from within an original string</p>
301 </div><div class="long"><p>Returns a substring from within an original string</p>
302 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The original text</p>
303 </div></li><li><span class="pre">start</span> : Number<div class="sub-desc"><p>The start index of the substring</p>
304 </div></li><li><span class="pre">length</span> : Number<div class="sub-desc"><p>The length of the substring</p>
305 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The substring</p>
306 </li></ul></div></div></div><div id="method-undef" class="member ni"><a href="Ext.util.Format.html#method-undef" rel="method-undef" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-undef" class="viewSource">view source</a></div><a name="undef"></a><a name="method-undef"></a><a href="Ext.util.Format.html#" rel="method-undef" class="cls expand">undef</a>(
307 <span class="pre">Mixed value</span>)
308 : Mixed</div><div class="description"><div class="short"><p>Checks a reference and converts it to empty string if it is undefined</p>
309 </div><div class="long"><p>Checks a reference and converts it to empty string if it is undefined</p>
310 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc"><p>Reference to check</p>
311 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Mixed</span> <p>Empty string if converted, otherwise the original value</p>
312 </li></ul></div></div></div><div id="method-uppercase" class="member ni"><a href="Ext.util.Format.html#method-uppercase" rel="method-uppercase" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-uppercase" class="viewSource">view source</a></div><a name="uppercase"></a><a name="method-uppercase"></a><a href="Ext.util.Format.html#" rel="method-uppercase" class="cls expand">uppercase</a>(
313 <span class="pre">String value</span>)
314 : String</div><div class="description"><div class="short"><p>Converts a string to all upper case letters</p>
315 </div><div class="long"><p>Converts a string to all upper case letters</p>
316 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The text to convert</p>
317 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The converted text</p>
318 </li></ul></div></div></div><div id="method-usMoney" class="member ni"><a href="Ext.util.Format.html#method-usMoney" rel="method-usMoney" class="expand more ar"><span> </span></a><div class="title"><div class="meta"><a href="Ext.util.Format.html" class="definedIn docClass">Ext.util.Format</a><br/><a href="../source/Format.html#Ext-util.Format-method-usMoney" class="viewSource">view source</a></div><a name="usMoney"></a><a name="method-usMoney"></a><a href="Ext.util.Format.html#" rel="method-usMoney" class="cls expand">usMoney</a>(
319 <span class="pre">Number/String value</span>)
320 : String</div><div class="description"><div class="short"><p>Format a number as US currency</p>
321 </div><div class="long"><p>Format a number as US currency</p>
322 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number/String<div class="sub-desc"><p>The numeric value to format</p>
323 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span> <p>The formatted currency string</p>
324 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>