0

Insert grid template row (within grid) under condition

asked 2019-05-03 07:31:39 +0800

FrankV427 gravatar image FrankV427
5 2

updated 2019-05-03 07:38:53 +0800

In a facebook-esque fasion, I'm working in a post with comments. The comments have a int which indicates the id of the parent post. So Comment 1 and 2 both have assigned as parent Post 1. What im working on is on displaying them as a grid within a grid. Here is the .zul:

<grid id="postGrid" height="550px" model="@load(vm.pcdata.posts)" emptyMessage="No Posts.">
    <template name="model">
        <row>
            <window border="normal">

                <!-- .................. -->
                <!-- PARENT POST -->
                <!-- .................. -->

                <caption id="userPost" label="@load(each.user)"/>
                <textbox id="infoPost" readonly="true" value="@load(each.info)" multiline="true" rows="4" width="100%" mold="rounded"/>
                <separator bar="true"/> 

                <hlayout>

                    <div>
                        <button label="Like" onClick="@command('addPLike', postid=each.postid)"/>
                    </div>

                    <div hflex="true">
                        <textbox id="likeTB" disabled="true" width="40px" style="text-align:center" value="@load(each.plikes)"/>
                    </div>

                </hlayout>

                <separator bar="false"/>

                <window border="normal">

                    <!-- .................. -->
                    <!-- THE SECOND GRID-->
                    <!-- .................. -->

                    <grid id="commentGrid" height="150px" model="@load(vm.pcdata.comments)" emptyMessage="No Comments.">

                        <template name="model">

                                <row>

                                    <window border="normal">

                                        <caption id="userComment" label="@load(each.user)"/>
                                        <textbox id="infoComment" readonly="true" value="@load(each.info)" multiline="true" rows="4" width="100%" mold="rounded"/>
                                        <separator bar="true"/> 
                                        <hlayout>

                                            <div>
                                                <button label="Like" onClick="@command('addCLike', commentid=each.commentid)"/>
                                            </div>

                                            <div hflex="true">
                                                <textbox id="likeTB" disabled="true" width="40px" style="text-align:center" value="@load(each.clikes)"/>
                                            </div>

                                        </hlayout></window></row></template></grid></window></window></row></template></grid>

In the second grid, I imagine there could be some sort of if function in which if both the postid in the father Post and the postsrc in the child Comment are the same, the comment will be displayed. Is there any way to make this work?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-05-03 17:18:44 +0800

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

You can use shadow element <if>, e.g.

<if test="@load(vm.yourFlag)">
    <grid id="commentGrid">
    ....
</if>

please see http://books.zkoss.org/zk-mvvm-book/8.0/shadowelements/flowcontrol.html

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: 2019-05-03 07:31:39 +0800

Seen: 11 times

Last updated: May 03 '19

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