@template"
From Documentation
m ((via JWB)) |
|||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/syntax/template.html zk-mvvm-book/8.0/syntax/data_binding/template]|}} | ||
=Syntax= | =Syntax= | ||
− | < | + | <code>@template(</code> ''[EL-expression]'' <code>)</code> |
= Description = | = Description = | ||
'''Target Attribute:''' model, children | '''Target Attribute:''' model, children | ||
− | '''Purpose:''' It should be used with < | + | '''Purpose:''' It should be used with <code>@bind</code>, <code>@load</code>. It determines which template to be used to render child components. |
The evaluation result of EL expression should be the name of a template which is used to render child components. The result template's name can be any template defined in the same id space. | The evaluation result of EL expression should be the name of a template which is used to render child components. The result template's name can be any template defined in the same id space. | ||
Line 18: | Line 19: | ||
<source lang="xml" > | <source lang="xml" > | ||
− | <combobox model="@bind(item.options ) @template( | + | <combobox model="@bind(item.options ) @template(forEachStatus.index eq 0 or forEachStatus.index eq 2?'model1':'model2')"> |
<template name="model1" var="option" > | <template name="model1" var="option" > | ||
<comboitem label="@bind(optionStatus)" description="@bind(option)"/> | <comboitem label="@bind(optionStatus)" description="@bind(option)"/> | ||
Line 47: | Line 48: | ||
* vm.nodes has a tree-like structure, and node.children is a collection of node. | * vm.nodes has a tree-like structure, and node.children is a collection of node. | ||
+ | =Version History= | ||
− | + | {| class='wikitable' | width="100%" | |
− | |||
− | |||
− | |||
− | {| | ||
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- |
Latest revision as of 07:35, 8 July 2022
This article is out of date, please refer to zk-mvvm-book/8.0/syntax/data_binding/template for more up to date information.
Syntax
@template(
[EL-expression] )
Description
Target Attribute: model, children
Purpose: It should be used with @bind
, @load
. It determines which template to be used to render child components.
The evaluation result of EL expression should be the name of a template which is used to render child components. The result template's name can be any template defined in the same id space.
Example
Dynamic template upon iteration status variable
<combobox model="@bind(item.options ) @template(forEachStatus.index eq 0 or forEachStatus.index eq 2?'model1':'model2')">
<template name="model1" var="option" >
<comboitem label="@bind(optionStatus)" description="@bind(option)"/>
</template>
<template name="model2" var="option" >
<comboitem label="@bind(optionStatus)" description="@bind(option)"/>
</template>
</combobox>
Recursive usage
<vlayout id="vlayout" children="@load(vm.nodes) @template('greenBox')">
<template name="greenBox" var="node">
<vlayout style="padding-left:10px; border:2px solid green;" >
<label value="@bind(node.name)" />
<vlayout
children="@load(node.children) @template('greenBox')" />
</vlayout>
</template>
</vlayout>
- vm.nodes has a tree-like structure, and node.children is a collection of node.
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |