Chosenbox Template"

From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} Similar to Listbox, you can render a chosenbox with a template. However, noti...")
 
m (replace tt with code (via JWB))
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
Similar to [[ZK Developer's Reference/MVC/View/Template/Listbox Template|Listbox]], you can render a chosenbox with a template. However, notice that, unlike other components, chosenbox doesn't allow any child component, so you have to render  each item as a string. For example,
 
Similar to [[ZK Developer's Reference/MVC/View/Template/Listbox Template|Listbox]], you can render a chosenbox with a template. However, notice that, unlike other components, chosenbox doesn't allow any child component, so you have to render  each item as a string. For example,
  
<source lang="xml" high="2,3">
+
<source lang="xml" highlight="2,3">
 
<chosenbox model="${users}" onSelect='alert(model.get(event.getData()));'>
 
<chosenbox model="${users}" onSelect='alert(model.get(event.getData()));'>
 
<template name="model">
 
<template name="model">
Line 11: Line 11:
 
</source>
 
</source>
  
where we assume there is a list model (<javadoc>org.zkoss.zul.ListModel</javadoc>) called <tt>users</tt>  such as:
+
where we assume there is a list model (<javadoc>org.zkoss.zul.ListModel</javadoc>) called <code>users</code>  such as:
  
 
<source lang="java">
 
<source lang="java">
Line 19: Line 19:
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Revision as of 14:12, 12 January 2022


Chosenbox Template


Similar to Listbox, you can render a chosenbox with a template. However, notice that, unlike other components, chosenbox doesn't allow any child component, so you have to render each item as a string. For example,

<chosenbox model="${users}" onSelect='alert(model.get(event.getData()));'>
	<template name="model">
		Name is ${each}
	</template>
</chosenbox>

where we assume there is a list model (ListModel) called users such as:

ListModelList model = new ListModelList(new String[] { "Tony", "Ryan", "Jumper", "Wing", "Sam" });

Version History

Last Update : 2022/01/12


Version Date Content
6.0.1 April 2012 The chosenbox component was introduced.
6.0.0 July 2011 The template feature was introduced.



Last Update : 2022/01/12

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.