0

Grid with multiple template

asked 2016-04-21 12:02:10 +0800

Neus gravatar image Neus
1415 14

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!

delete flag offensive retag edit

Comments

grid in grid or maybe use detail (with children="@load(center.list)" ) of a grid.

chillworld ( 2016-04-21 12:45:50 +0800 )edit

I 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 )edit

Use 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 )edit

btw, untested with removing items from model, so check this out first.

chillworld ( 2016-04-21 14:10:43 +0800 )edit

http://zkfiddle.org/sample/28df0bi/2-grid-mvvm-alternating-place => with remove button.

chillworld ( 2016-04-21 14:15:58 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-04-22 04:14:16 +0800

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

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>
link publish delete flag offensive edit
0

answered 2016-04-22 04:35:04 +0800

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

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.

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

Follow
1 follower

RSS

Stats

Asked: 2016-04-21 12:02:10 +0800

Seen: 103 times

Last updated: Apr 22 '16

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