-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm new to ZK and being Italian, I can't fully understand documentation. Readed all way long through that but still not found a proper solution. I encounter this problem: I have a model called StatisticGroup, each of them has a property called operators, containing a collection of Operator(s). For clarity, a StatisticGroup can have many Operator(s) and an Operator belongs to a StatisticGroup. I need to show these Operator(s) in a <grid>
element, with their StatisticGroup as a <group>
element. I saw a nested template example in docs but didn't understand it.
How can i display these data (Operators) within a nested template?
StatisticGroup model
public class StatisticGroup implements Serializable
{
private long id;
private long name;
private List<Operator> operators;
// Omitted getters and setters.
}
Operator model
public class Operator implements Serializable
{
private long id;
private string firstName;
private string lastName;
// Omitted getters and setters.
}
*Controller *
public class ControllerOperators extends SelectorComposer<Component>
{
@Wire
private Grid grid;
public ArrayList<StatisticGroup> StatisticGroups;
@Listen("onCreate = #grid")
public void creaGriglia()
{
this.StatisticGroups = fetchStatisticGroupFromDB();
tabella.setModel(new ListModelList<StatisticGroup>(StatisticGroups));
}
}
* ZUL page *
<grid id="grid">
<columns sizable="true">
<column label="Last Name"/>
<column label="First Name"/>
</columns>
<rows>
<template name="model">
<group label="${each.name}"/> // The StatisticGroup name.
<template name="model">
<row>
<label value="I have to show Last Name for each operator"/>
<label value="I have to show First Name for each operator"/>
</row>
</template>
</template>
</rows>
</grid>
There are some runnable examples at GitHub. You can download the whole project and run it which will express more clearly than texts.
Asked: 2019-03-21 22:17:14 +0800
Seen: 12 times
Last updated: Mar 22 '19
ZK, AngularJS and Pure HTML Template
Template like functionality for a single value?
Conditional Template and GroupModel not working.
ZK Framework using template files
Center template using every page
MVC Modify model object in zul
Templating and Including Another Webpage (or another ZK app) in Frame