webgui/www/extras/extjs/docs/output/Ext.util.Format.html

354 lines
No EOL
18 KiB
HTML

<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ext.util.Format</title>
<link rel="stylesheet" type="text/css" href="../resources/reset.css"/>
<link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="../resources/print.css" media="print">
<!-- GC -->
</head>
<body>
<div class="body-wrap">
<div class="top-tools">
<img src="../resources/print.gif" width="16" height="16" align="absmiddle">&nbsp;<a href="Ext.util.Format.html" target="_blank">Print Friendly</a><br/>
</div>
<h1>Class Ext.util.Format</h1>
<table cellspacing="0">
<tr><td class="label">Package:</td><td>Ext.util</td></tr>
<tr><td class="label">Class:</td><td>Format</td></tr>
<tr><td class="label">Extends:</td><td>Object</td></tr>
<tr><td class="label">Defined In:</td><td><a href="Format.jss.html">Format.js</a></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>
<br />
<a href="#properties">Properties</a>
&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#methods">Methods</a>
&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#events">Events</a>
<hr />
<a name="properties"></a>
<h2>Public Properties</h2>
<div class="no-members">This class has no public properties.</div> <a name="methods"></a>
<h2>Public Methods</h2>
<table cellspacing="0" class="member-table">
<tr>
<th class="sig-header" colspan="2">Method</th>
<th class="msource-header">Defined By</th>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#capitalize">capitalize</a>(<code>String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Converts the first character only of a string to upper case</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#date">date</a>(<code>Mixed value</code>, <span class="optional" title="Optional">[<code>String format</code>]</span>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Parse a value into a formatted date using the specified format pattern.</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#dateRenderer">dateRenderer</a>(<code>String format</code>) : Function</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Returns a date rendering function that can be reused to apply a date format multiple times efficiently</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#ellipsis">ellipsis</a>(<code>String value</code>, <code>Number length</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#htmlEncode">htmlEncode</a>(<code>String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#lowercase">lowercase</a>(<code>String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Converts a string to all lower case letters</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#stripTags">stripTags</a>(<code>Mixed value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Strips all HTML tags</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#substr">substr</a>(<code>String value</code>, <code>Number start</code>, <code>Number length</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Returns a substring from within an original string</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#trim">trim</a>(<code>String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Trims any whitespace from either side of a string</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#undef">undef</a>(<code>Mixed value</code>) : Mixed</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Checks a reference and converts it to empty string if it is undefined</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#uppercase">uppercase</a>(<code>String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr>
<td class="mdesc">Converts a string to all upper case letters</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#usMoney">usMoney</a>(<code>Number/String value</code>) : String</td>
<td class="msource" rowspan="2">Format</td>
</tr>
<tr class="alt">
<td class="mdesc">Format a number as US currency</td>
</tr>
</table>
<a name="events"></a>
<h2>Public Events</h2>
<div class="no-members">This class has no public events.</div>
<h2 class="mdetail-head">Method Details</h2>
<div class="detail-wrap">
<a name="capitalize"></a>
<div class="mdetail">
<h3>capitalize</i></h3>
<code>public function capitalize(<code>String value</code>)</code>
<div class="mdetail-desc">
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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="date"></a>
<div class="mdetail alt">
<h3>date</i></h3>
<code>public function date(<code>Mixed value</code>, <span class="optional" title="Optional">[<code>String format</code>]</span>)</code>
<div class="mdetail-desc">
Parse a value into a formatted date using the specified format pattern.
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</code> : Mixed<div class="sub-desc">The value to format</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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="dateRenderer"></a>
<div class="mdetail">
<h3>dateRenderer</i></h3>
<code>public function dateRenderer(<code>String format</code>)</code>
<div class="mdetail-desc">
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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="ellipsis"></a>
<div class="mdetail alt">
<h3>ellipsis</i></h3>
<code>public function ellipsis(<code>String value</code>, <code>Number length</code>)</code>
<div class="mdetail-desc">
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> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code><div class="sub-desc">The converted text</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="htmlEncode"></a>
<div class="mdetail">
<h3>htmlEncode</i></h3>
<code>public function htmlEncode(<code>String value</code>)</code>
<div class="mdetail-desc">
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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="lowercase"></a>
<div class="mdetail alt">
<h3>lowercase</i></h3>
<code>public function lowercase(<code>String value</code>)</code>
<div class="mdetail-desc">
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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="stripTags"></a>
<div class="mdetail">
<h3>stripTags</i></h3>
<code>public function stripTags(<code>Mixed value</code>)</code>
<div class="mdetail-desc">
Strips all HTML tags
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</code> : Mixed<div class="sub-desc">The text from which to strip tags</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code><div class="sub-desc">The stripped text</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="substr"></a>
<div class="mdetail alt">
<h3>substr</i></h3>
<code>public function substr(<code>String value</code>, <code>Number start</code>, <code>Number length</code>)</code>
<div class="mdetail-desc">
Returns a substring from within an original string
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</code> : String<div class="sub-desc">The original text</div></li><li><code>start</code> : Number<div class="sub-desc">The start index of the substring</div></li><li><code>length</code> : Number<div class="sub-desc">The length of the substring</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code><div class="sub-desc">The substring</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="trim"></a>
<div class="mdetail">
<h3>trim</i></h3>
<code>public function trim(<code>String value</code>)</code>
<div class="mdetail-desc">
Trims any whitespace from either side of a string
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</code> : String<div class="sub-desc">The text to trim</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code><div class="sub-desc">The trimmed text</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="undef"></a>
<div class="mdetail alt">
<h3>undef</i></h3>
<code>public function undef(<code>Mixed value</code>)</code>
<div class="mdetail-desc">
Checks a reference and converts it to empty string if it is undefined
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</code> : Mixed<div class="sub-desc">Reference to check</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Mixed</code><div class="sub-desc">Empty string if converted, otherwise the original value</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="uppercase"></a>
<div class="mdetail">
<h3>uppercase</i></h3>
<code>public function uppercase(<code>String value</code>)</code>
<div class="mdetail-desc">
Converts a string to all upper 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 class="mdetail-def">This method is defined by Format.</div>
</div>
<a name="usMoney"></a>
<div class="mdetail alt">
<h3>usMoney</i></h3>
<code>public function usMoney(<code>Number/String value</code>)</code>
<div class="mdetail-desc">
Format a number as US currency
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>value</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 currency string</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Format.</div>
</div>
</div>
</div>
<hr>
<div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright &copy; 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
</body>
</html>