-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a complex zul file with one section containing a grid (could use a listbox) that displays data from a set. I would use a template with databinding, but I want to change the element type for each row to be a textbox or a datebox based on the type of data. I see that a rowrenderer can do exactly what I want for changing the element type, but I also need databinding so that I can easily save off the changed data. What is the best way to accomplish this? In case it matters, I am using zk6.
You can achieve that in a <grid>
or <listbox>
using model and Dynamic Template. Define a template with <textbox>
, and another one with a <datebox>
, and switch the template name according to the type of each element in the listModel.
This example will switch the content according to the value in the type attribute of each element
<grid model="@load(vm.listModel) @template(each.type)">
<rows>
<template name="date">
<row>
<datebox></datebox>
</row>
</template>
<template name="text">
<row>
<textbox></textbox>
</row>
</template>
</rows>
</grid>
Asked: 2013-05-07 17:42:18 +0800
Seen: 28 times
Last updated: May 14 '13
That worked perfectly. Thanks!
mhlic ( 2013-05-14 21:29:11 +0800 )edit