Class Ext.MasterTemplate
Provides a template that can have child templates. The syntax is:
var t = new Ext.MasterTemplate(
'<select name="{name}">',
'<tpl name="options"><option value="{value:trim}">{text:ellipsis(10)}</option></tpl>',
'</select>'
);
t.add('options', {value: 'foo', text: 'bar'});
// or you can add multiple child elements in one shot
t.addAll('options', [
{value: 'foo', text: 'bar'},
{value: 'foo2', text: 'bar2'},
{value: 'foo3', text: 'bar3'}
]);
// then append, applying the master template values
t.append('my-form', {name: 'my-select'});
A name attribute for the child template is not required if you have only one child
template or you want to refer to them by index.
属性
-
方法
-
事件
公共属性
|
disableFormats : Boolean |
Template |
True to disable format functions (default to false) |
|
re : RegExp |
Template |
The regular expression used to match template variables |
|
subTemplateRe : RegExp |
MasterTemplate |
The regular expression used to match sub templates |
公共方法
|
MasterTemplate.from(String/HTMLElement el ) : void |
MasterTemplate |
<static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML. e.... |
|
add([String/Number name ], Array/Object values ) : MasterTemplate |
MasterTemplate |
Applies the passed values to a child template. |
|
addAll() : void |
MasterTemplate |
Alias for fill(). |
|
append(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and append the new node(s) to el |
|
apply() : void |
Template |
Alias for applyTemplate |
|
applyTemplate(Object values ) : String |
Template |
Returns an HTML fragment of this template with the specified values applied |
|
compile() : void |
Template |
Compiles the template into an internal function, eliminating the RegEx overhead |
|
fill([String/Number name ], Array values , [Boolean reset ]) : MasterTemplate |
MasterTemplate |
Applies all the passed values to a child template. |
|
insertAfter(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) after el |
|
insertBefore(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) before el |
|
insertFirst(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) as the first child of el |
|
overwrite(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and overwrites the content of el with the new node(s) |
|
reset() : MasterTemplate |
MasterTemplate |
Resets the template for reuse |
|
set(String html , [Boolean compile ]) : Template |
Template |
Sets the html used as the template and optionally compiles it |
公共事件
此类没有公共事件。
属性详情
disableFormats
public Boolean disableFormats
True to disable format functions (default to false)
re
public RegExp re
The regular expression used to match template variables
subTemplateRe
public RegExp subTemplateRe
The regular expression used to match sub templates
This property is defined by MasterTemplate.
方法详情
MasterTemplate.from
public function MasterTemplate.from(String/HTMLElement el
)
<static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML. e.g.
var tpl = Ext.MasterTemplate.from('element-id');
This method is defined by MasterTemplate.
add
public function add([String/Number name
], Array/Object values
)
Applies the passed values to a child template.
This method is defined by MasterTemplate.
addAll
public function addAll()
This method is defined by MasterTemplate.
append
public function append(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and append the new node(s) to el
apply
public function apply()
applyTemplate
public function applyTemplate(Object values
)
Returns an HTML fragment of this template with the specified values applied
compile
public function compile()
Compiles the template into an internal function, eliminating the RegEx overhead
fill
public function fill([String/Number name
], Array values
, [Boolean reset
])
Applies all the passed values to a child template.
参数:
name
: String/Number(可选) The name or index of the child template
values
: ArrayThe values to be applied to the template, this should be an array of objects.
reset
: Boolean(可选) True to reset the template first
返回:
This method is defined by MasterTemplate.
insertAfter
public function insertAfter(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) after el
insertBefore
public function insertBefore(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) before el
insertFirst
public function insertFirst(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) as the first child of el
overwrite
public function overwrite(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and overwrites the content of el with the new node(s)
reset
public function reset()
Resets the template for reuse
This method is defined by MasterTemplate.
set
public function set(String html
, [Boolean compile
])
Sets the html used as the template and optionally compiles it
参数:
html
: Stringcompile
: Boolean(可选)
返回: