asked
2015-08-17 11:48:56 +0800
Neus 1415 ● 14 Hi,
I have a bean like this:
public class MyBean{
private String id = "";
private String name = "";
private Arraylist<SubClass> subclasses = new Arraylist<SubClass>();
}
I want to load a list of this type of beans inside a grid so that the two first cells represents the name and the id and must rowspan the size of the subclasses list. So, for every subclass in each MyBean I have to create one row.
MyBeanId MyBeanName SubClassCol1 SubClassCol2
-------- ----------- --------------- ---------------
SC1.1.1 SC1.2.1
1 N1 SC1.1.2 SC1.2.2
SC1.1.3 SC1.2.3
---------------------------------------------------
2 N2 SC2.1.1 SC2.2.1
---------------------------------------------------
SC3.1.1 SC3.2.1
3 N3 SC3.1.2 SC3.2.2
I want to do this with MVVM.
Any idea of how to do it?
Thank you!
EDIT:
I need different rows for each children, not different cells in the same row. Something like...
<listbox model="@load(vm.myBeans)>
<template name="model" var="myBean" children="@load(each.subclasses)>
<template name="children" var="item">
<listitem>
<listcell value="@load(myBean.MyBeanId)" rowspan="@load(myBean.subclasses.indexof(item) eq 0 ? myBean.subclasses.size : 1)"/>
<listcell value="@load(myBean.MyBeanName)" rowspan="@load(myBean.subclasses.indexof(item) eq 0 ? myBean.subclasses.size : 1)"/>
<listcell value="@load(item.SubClassCol1"/>
<listcell value="@load(item.SubClassCol2"/>
</listitem>
</template>
</template>
</listbox>
zk fiddle example
But this doesn't work. I can't put a template inside a template. But I think with this example you can imagine what I want to achieve