I need to display objects in a model row-wise, with two models in each row. In my zul file I have to group the models in groups of two. How is it possible using foreach, foreachstatus or template ? I am using zk grid
How to iterate models in zk over even index?
4.3k Views Asked by Harry At
2
There are 2 best solutions below
0
On
Greets, AFAIK you can apply only 1 model to your grid..of course you can manipulate it on the controller side However, if you want to know the element index of your iteration with the template component, use @load( varName Status.index) example:
<template name="model" var="element">
then inside the template:
<label value="@load(elementStatus.index)" />
and it'll output the position of the element inside the model
more infos here
Here is an example witch switch between 2 templates on the index.
You just have to implement the modulo 2 and check for 1 or 0.
http://www.zkfiddle.org/sample/2rjaqos/4-MVVM-with-nested-template
zul code of that link :
here another example with the modulo but with 1 template :
http://zkfiddle.org/sample/2pmngjk/9-Listbox-with-Template
Zul code of second example :