Make a grid with nested template

asked 2019-03-21 22:17:14 +0800

MarcoCons gravatar image MarcoCons
1 1

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>
  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"/>
    <template name="model">
      <group label="${each.name}"/> // The StatisticGroup name.
        <template name="model">
            <label value="I have to show Last Name for each operator"/>
            <label value="I have to show First Name for each operator"/>
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-22 12:00:58 +0800

hawk gravatar image hawk
2310 1 5
http://hawkphoenix.blogsp... ZK Team

There are some runnable examples at GitHub. You can download the whole project and run it which will express more clearly than texts.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2019-03-21 22:17:14 +0800

Seen: 10 times

Last updated: Mar 22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More