Difference between revisions of "Template:CustomItemRendering"

From Documentation
Line 4: Line 4:
 
== Change text ==
 
== Change text ==
 
If you just want to change the text e.g. enclosing it with brackets, just put <code><template></code> as its child and add characters with <code>${each}</code>:
 
If you just want to change the text e.g. enclosing it with brackets, just put <code><template></code> as its child and add characters with <code>${each}</code>:
{{{1}}}
+
 
<syntaxhighlight line lang='xml'>
+
 
<{{{1}}}>
+
    <{{{1}}}>
    <template name="model">[${each}]</template>
+
        <template name="model">[${each}]</template>
</{{{1}}}>
+
    </{{{1}}}>
</syntaxhighlight>
+
 
  
 
* The template only allows text that can be converted into a ZK <code>Label</code>.
 
* The template only allows text that can be converted into a ZK <code>Label</code>.

Revision as of 04:01, 5 December 2023

Custom Item Rendering

Since this component has no child component like Listbox, if you want to render its items differently, there 2 ways:

Change text

If you just want to change the text e.g. enclosing it with brackets, just put <template> as its child and add characters with ${each}:


   <{{{1}}}>
       <template name="model">[${each}]</template>
   </{{{1}}}>


  • The template only allows text that can be converted into a ZK Label.

Change HTML Structure

If you want to make more changes e.g. adding tooltips by setting title attributes, you need to create your own ItemRenderer. See ZK Developer's Reference/MVC/View/Renderer/Item Renderer.