How to iterativly print label in zk using templates with mvvm style

363 views Asked by At
<window apply="org.zkoss.bind.BindComposer"
    viewModel="@id('vm') @init('com.test.labelTest')">

    <template <!--model = "@bind(vm.allLabelSets)" some thing like this --> >
        <label value="@load(each.label1)" />
        <label value="@load(each.label2)" />
        <label value="@load(each.label3)" />
    </template>

</window>

how can we use template to iterate over a list without using any of gridModel,treeModel ?

1

There are 1 answers

0
Subodh Joshi On BEST ANSWER

Try this below code

<vlayout id="vlayout" children="@bind(vm.allLabelSets) @template('record')">
    <template name="record" var="record">
        <vlayout style="padding-left:10px; border:2px solid green;" >
         <label value="@load(each.label1)" />
         <label value="@load(each.label2)" />
         <label value="@load(each.label3)" />

        </vlayout>
    </template>
</vlayout>

You have to use children attribute