Revision history [back]

click to hide/show revision 1
initial version

answered 2015-06-15 08:18:25 +0800

cor3000 gravatar image cor3000

ZK Team

you can use a dynamic template name to render either a normal row or a fake row based on a condition in the @template() annotation.

<grid id="vehicleGrid" model="@load(vm.vehModel) @template(each.faker ? 'faker' : 'model')" vflex="1" sclass="noscroll" width="250px">
  <custom-attributes org.zkoss.zul.nativbar="true"/>
    <columns >
            <column label="Vehicles" align="center" style="font-size: 8pt"/>
    </columns>
  <template name="model" >
    <row align="center" height="33px">
      <label style="font-size: 8pt; white-space:nowrap;" value="@load(each)" tooltiptext="@load(each)" />
    </row>
  </template>
  <template name="faker" >
    <row><label value="" id="faker"/></row>
  </template>
</grid>

in the example above I assume the item in the vm.vehModel has a method public boolean isFaker();

Any other condition is possible e.g:

@template(vm.isFaker(each) ? 'faker' : 'model') @template(each.type ne 'faker' ? 'model' : 'faker') @template(each eq null ? 'faker' : 'model') (in case you add a null value for the faker)

The principle is always the same, if something remains unclear let me know.

Robert

you can use a dynamic template name to render either a normal row or a fake row based on a condition in the @template() annotation.

<grid id="vehicleGrid" model="@load(vm.vehModel) @template(each.faker ? 'faker' : 'model')" vflex="1" sclass="noscroll" width="250px">
  <custom-attributes org.zkoss.zul.nativbar="true"/>
    <columns >
            <column label="Vehicles" align="center" style="font-size: 8pt"/>
    </columns>
  <template name="model" >
    <row align="center" height="33px">
      <label style="font-size: 8pt; white-space:nowrap;" value="@load(each)" tooltiptext="@load(each)" />
    </row>
  </template>
  <template name="faker" >
    <row><label value="" id="faker"/></row>
  </template>
</grid>

in the example above I assume the item in the vm.vehModel has a method public boolean isFaker();

Any other condition is possible Arbitrary conditions are possible e.g:

  • @template(vm.isFaker(each) ? 'faker' : 'model') 'model')
  • @template(each.type ne 'faker' ? 'model' : 'faker') 'faker')
  • @template(each eq null ? 'faker' : 'model') (in case you add a null value for the faker)

The principle is always the same, if something remains unclear let me know.

Robert

you can use a dynamic template name to render either a normal row or a fake row based on a condition in the @template() annotation.

<grid id="vehicleGrid" model="@load(vm.vehModel) @template(each.faker ? 'faker' : 'model')"  vflex="1" sclass="noscroll" width="250px">
  <custom-attributes org.zkoss.zul.nativbar="true"/>
    <columns >
       <column label="Vehicles" align="center" style="font-size: 8pt"/>
    </columns>
  <template name="model" >
    <row align="center" height="33px">
      <label style="font-size: 8pt; white-space:nowrap;"  value="@load(each)" tooltiptext="@load(each)" />
    </row>
  </template>
  <template name="faker" >
    <row><label value="" id="faker"/></row>
  </template>
</grid>

in the example above I assume the item in the vm.vehModel has a method public boolean isFaker();

Arbitrary conditions are possible e.g:

  • @template(vm.isFaker(each) ? 'faker' : 'model')
  • @template(each.type ne 'faker' ? 'model' : 'faker')
  • @template(each eq null ? 'faker' : 'model') (in case you add a null value for the faker)

The principle is always the same, if something remains unclear let me know.

Robert

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