3

ZUL ファイルに <template> タグがあり、何らかの条件が満たされた場合 (たとえば、LABEL の値がテキストに変更された場合) にこのテンプレートを使用したいと考えています。

以下のコードを見てください...ご覧のとおり、「templateStatus」は私のラベルの名前ですが、機能しませんでした。

この問題を解決するにはどうすればよいですか?

    <template name="allTaskTemplate" var="allTask" if="templateStatus.value == 'allTask'">
        <row>
            <label value="" />
            <label value="@load(allTask.documentDTO.docTypeDTO.title)"/>
            <label value="@load(allTask.documentDTO.docNumber)"/>
            <label value="@load(allTask.documentDTO.docDateTime)"/>
            <label value="@load(allTask.assignerID)"/>
            <label value="@load(allTask.assigneeID)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.documentDTO.docTypeStateDTO.stateActionDTO.actionDTO.title)"/>
            <label value="@load(allTask.catalogDTO.catalogTypeDTO.title)"/>
        </row>
    </template>
</grid>
4

2 に答える 2

5

ifステートメントの使用:

<zk if="${vm.type=='foo'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='check'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='something'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='value'}">
    <!-- Child components -->
</zk>
于 2013-06-18T12:40:40.443 に答える
2

See the below example of ZK. You can use conditional templates...

<grid model="@bind(vm.itemList) @template(vm.type eq 'foo'?'template1':'template2')">
    <template name="template1">
    <!-- child components -->
    </template>

    <template name="template2">
    <!-- child components -->
    </template>
</grid>

For more information, you can see the official page of ZK, Collection and Selection.

Se the below code for...

   <menubar id="mbar" children="@bind(vm.menuList) @template(empty each.children?'menuitem':'menu')">
    <template name="menu" var="menu">
        <menu label="@bind(menu.name)">
            <menupopup children="@bind(menu.children) @template(empty each.children?'menuitem':'menu')"/>
        </menu>
    </template>
    <template name="menuitem" var="item">
        <menuitem label="@bind(item.name)" onClick="@command('menuClicked',node=item)" />
    </template>
</menubar>

See the above. Using more than two templates you can do something like this. I don't know your requirement, but you can use the above logic and implement it in your code.

Or you can see the ZK Forum for the same, Zk forum.

于 2013-03-11T07:15:50.993 に答える