-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I have a class like this:
Center.java
public class Center{
private String name = "";
private List<Detail> list = new ArrayList<Detail>();
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void getList(){
return list;
}
}
And i want to populate a Grid with Centers the following way: For each center I want to create a row tih the name of the center. After that row, I want to create one row for each Detail in the center List<detail>
I can't find how to do it using mvvm I tried:
<grid model="@load(vm.centers)">
<columns>
(...)
</columns>
<rows>
<template name="model" var="center">
<row>
<cell colspan="17">
<label value="@load(centro.nombre)"/>
</cell>
</row>
</template>
<!-- Here I don't know how to load the detail of the center --->
</rows>
</grid>
Any idea on how can I do this??
Thank you!
Only one <row>
is allowed in a Grid's <template>
only for now. The alternative:
Use a groupbox to show the detail
<grid model="@load(vm.model)">
<template name="model">
<row>
<cell>
<label value="@load(each)"/>
<groupbox open="false">
<caption label="detail" />
<label value="@load(each.detail)"/>
</groupbox>
</cell>
</row>
</template>
</grid>
Another alternative: store Center and its detail in your model and render them with 2 different templates with @template
Collection Property Binding with Dynamic Template
or render the model with your custom grid-like layout with XHTML components and data binding.
Asked: 2016-04-21 12:02:10 +0800
Seen: 102 times
Last updated: Apr 22 '16
grid in grid or maybe use detail (with children="@load(center.list)" ) of a grid.
chillworld ( 2016-04-21 12:45:50 +0800 )editI can't use detail because I'm developing with ZK CE, and I think detail is from ZK EE. Am I right? I will try with Grid insight Grid... And what can I do if I want to create for each center another row with some text in an expanded cell? It seem that I can put just one row inside a template. Thanks
Neus ( 2016-04-21 13:37:47 +0800 )editUse a rowrenderer, but the other way around like this : https://stackoverflow.com/questions/36644340/zk-grid-several-columns-in-the-same-row/36768112#36768112
chillworld ( 2016-04-21 14:09:02 +0800 )editbtw, untested with removing items from model, so check this out first.
chillworld ( 2016-04-21 14:10:43 +0800 )edithttp://zkfiddle.org/sample/28df0bi/2-grid-mvvm-alternating-place => with remove button.
chillworld ( 2016-04-21 14:15:58 +0800 )edit