Chosenbox Renderer"

From Documentation
m (replace tt with code (via JWB))
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
 
</source>
 
</source>
  
Then, if we have a list model (<javadoc>org.zkoss.zul.ListModel</javadoc>) called <tt>users</tt>, and an instance of a custom renderer called <tt>userRenderer</tt>, then we can put them together in a ZUML document as follows:
+
Then, if we have a list model (<javadoc>org.zkoss.zul.ListModel</javadoc>) called <code>users</code>, and an instance of a custom renderer called <code>userRenderer</code>, then we can put them together in a ZUML document as follows:
  
 
<source lang="xml">
 
<source lang="xml">
Line 24: Line 24:
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Latest revision as of 14:12, 12 January 2022


Chosenbox Renderer


The implementation of a custom renderer for a Chosenbox (ItemRenderer) is straightforward[1]:

public class FooItemRenderer implements org.zkoss.zul.ItemRenderer {
    public String render(Component owner, Object data, int index) throws Exception {
        return data.toString(); //converting data to a string; it depends on your application's requirement
    }
}

Then, if we have a list model (ListModel) called users, and an instance of a custom renderer called userRenderer, then we can put them together in a ZUML document as follows:

<chosenbox model="${users}" itemRenderer="${userRenderer}"/>

  1. For the concept about component, model and renderer, please refer to the Model-driven Display section.

Version History

Last Update : 2022/01/12


Version Date Content
6.0.1 April 2012 Chosenbox was introduced.


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