webgui/www/extras/extjs/docs/output/Ext.Template.html

377 lines
No EOL
21 KiB
HTML

<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ext.Template</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.Template.html" target="_blank">Print Friendly</a><br/>
</div>
<h1>Class Ext.Template</h1>
<table cellspacing="0">
<tr><td class="label">Package:</td><td>Ext</td></tr>
<tr><td class="label">Class:</td><td>Template</td></tr>
<tr><td class="label">Extends:</td><td>Object</td></tr>
<tr><td class="label">Subclasses:</td><td><a href="Ext.MasterTemplate.html">MasterTemplate</a></td></tr>
<tr><td class="label">Defined In:</td><td><a href="Template.jss.html">Template.js</a></td></tr>
</table>
<div class="description">
Represents an HTML fragment template. Templates can be precompiled for greater performance.
For a list of available format functions, see <a href="Ext.util.Format.html">Ext.util.Format</a>.
<pre class="highlighted"><code>var t = <b>new</b> Ext.Template(
'&lt;div name="{id}"&gt;',
'&lt;span class="{cls}"&gt;{name:trim} {value:ellipsis(10)}&lt;/span&gt;',
'&lt;/div&gt;'
);
t.append('some-element', {id: 'myid', name: 'foo', value: 'bar'});</code></pre>
For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>.
<br> </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>
<table cellspacing="0" class="member-table">
<tr>
<th class="sig-header" colspan="2">Property</th>
<th class="msource-header">Defined By</th>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#disableFormats">disableFormats</a> : Boolean</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">True to disable format functions (default to false)</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#re">re</a> : RegExp</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">The regular expression used to match template variables</td>
</tr>
</table>
<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="#Template">Template</a>(<code>String/Array html</code>)</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc"></td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#Template.from">Template.from</a>(<code>String/HTMLElement el</code>) : void</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">&lt;static&gt; Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#append">append</a>(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>) : HTMLElement</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">Applies the supplied values to the template and append the new node(s) to el</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#apply">apply</a>() : void</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">Alias for applyTemplate</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#applyTemplate">applyTemplate</a>(<code>Object values</code>) : String</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">Returns an HTML fragment of this template with the specified values applied</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#compile">compile</a>() : void</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">Compiles the template into an internal function, eliminating the RegEx overhead</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#insertAfter">insertAfter</a>(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>) : HTMLElement</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">Applies the supplied values to the template and inserts the new node(s) after el</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#insertBefore">insertBefore</a>(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>) : HTMLElement</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">Applies the supplied values to the template and inserts the new node(s) before el</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#insertFirst">insertFirst</a>(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>) : HTMLElement</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">Applies the supplied values to the template and inserts the new node(s) as the first child of el</td>
</tr>
<tr class="alt">
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#overwrite">overwrite</a>(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>) : HTMLElement</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr class="alt">
<td class="mdesc">Applies the supplied values to the template and overwrites the content of el with the new node(s)</td>
</tr>
<tr>
<td class="micon" rowspan="2">&nbsp;</td>
<td class="sig"><a class="mlink" href="#set">set</a>(<code>String html</code>, <span class="optional" title="Optional">[<code>Boolean compile</code>]</span>) : Template</td>
<td class="msource" rowspan="2">Template</td>
</tr>
<tr>
<td class="mdesc">Sets the html used as the template and optionally compiles it</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">Property Details</h2>
<div class="detail-wrap">
<a name="disableFormats"></a>
<div class="mdetail">
<h3>disableFormats</i></h3>
<code>public Boolean disableFormats</code>
<div class="mdetail-desc">
True to disable format functions (default to false) </div>
<div class="mdetail-def">This property is defined by Template.</div>
</div>
<a name="re"></a>
<div class="mdetail alt">
<h3>re</i></h3>
<code>public RegExp re</code>
<div class="mdetail-desc">
The regular expression used to match template variables </div>
<div class="mdetail-def">This property is defined by Template.</div>
</div>
</div>
<a name="Template"></a>
<h2 class="mdetail-head">Constructor Details</h2>
<div class="detail-wrap">
<div class="mdetail">
<h3>Template</i></h3>
<code>public function Template(<code>String/Array html</code>)</code>
<div class="mdetail-desc">
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>html</code> : String/Array<div class="sub-desc">The HTML fragment or an array of fragments to join('') or multiple arguments to join('')</div></li> </ul>
</div>
</div>
</div>
</div>
<h2 class="mdetail-head">Method Details</h2>
<div class="detail-wrap">
<a name="Template.from"></a>
<div class="mdetail">
<h3>Template.from</i></h3>
<code>public function Template.from(<code>String/HTMLElement el</code>)</code>
<div class="mdetail-desc">
&lt;static&gt; Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement<div class="sub-desc"></div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="append"></a>
<div class="mdetail alt">
<h3>append</i></h3>
<code>public function append(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>)</code>
<div class="mdetail-desc">
Applies the supplied values to the template and append the new node(s) to el
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement/Element<div class="sub-desc">The context element</div></li><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="apply"></a>
<div class="mdetail">
<h3>apply</i></h3>
<code>public function apply()</code>
<div class="mdetail-desc">
Alias for applyTemplate
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="applyTemplate"></a>
<div class="mdetail alt">
<h3>applyTemplate</i></h3>
<code>public function applyTemplate(<code>Object values</code>)</code>
<div class="mdetail-desc">
Returns an HTML fragment of this template with the specified values applied
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="compile"></a>
<div class="mdetail">
<h3>compile</i></h3>
<code>public function compile()</code>
<div class="mdetail-desc">
Compiles the template into an internal function, eliminating the RegEx overhead
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="insertAfter"></a>
<div class="mdetail alt">
<h3>insertAfter</i></h3>
<code>public function insertAfter(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>)</code>
<div class="mdetail-desc">
Applies the supplied values to the template and inserts the new node(s) after el
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement/Element<div class="sub-desc">The context element</div></li><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="insertBefore"></a>
<div class="mdetail">
<h3>insertBefore</i></h3>
<code>public function insertBefore(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>)</code>
<div class="mdetail-desc">
Applies the supplied values to the template and inserts the new node(s) before el
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement/Element<div class="sub-desc">The context element</div></li><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="insertFirst"></a>
<div class="mdetail alt">
<h3>insertFirst</i></h3>
<code>public function insertFirst(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>)</code>
<div class="mdetail-desc">
Applies the supplied values to the template and inserts the new node(s) as the first child of el
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement/Element<div class="sub-desc">The context element</div></li><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="overwrite"></a>
<div class="mdetail">
<h3>overwrite</i></h3>
<code>public function overwrite(<code>String/HTMLElement/Element el</code>, <code>Object values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span>)</code>
<div class="mdetail-desc">
Applies the supplied values to the template and overwrites the content of el with the new node(s)
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement/Element<div class="sub-desc">The context element</div></li><li><code>values</code> : Object<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement</code><div class="sub-desc">The new node</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</div>
</div>
<a name="set"></a>
<div class="mdetail alt">
<h3>set</i></h3>
<code>public function set(<code>String html</code>, <span class="optional" title="Optional">[<code>Boolean compile</code>]</span>)</code>
<div class="mdetail-desc">
Sets the html used as the template and optionally compiles it
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>html</code> : String<div class="sub-desc"></div></li><li><code>compile</code> : Boolean<div class="sub-desc">(optional)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Template</code><div class="sub-desc">this</div></li>
</ul>
</div>
</div>
<div class="mdetail-def">This method is defined by Template.</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>