-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Not sure how to do this so looking for suggestions. We have dynamic dropdown list on our site for example:
<zk>
<listbox mold="select" rows="1">
<listitem label="Taxi"/>
<listitem label="Bus" selected="true"/>
<listitem label="Train"/>
</listbox>
</zk>
but when the list only has one listitem I would like the listbox to display as a label. So if I have
<zk>
<listbox mold="select" rows="1">
<listitem label="Taxi"/>
</listbox>
</zk>
I would like it to render as
<label value="Taxi" />
Any suggestions would be awesome, thank you
Hey Druiznyc,
Darksu is correct you can use the conditional evaluation.
The if attribute is not dynamic, so @load
you can't use there.
The advantage of if
against the usage of the visible
attribute is that when you use if
, it is not rendered in the HTML output, while visible
is rendered.
I have made a sample where you can check the usage of it.
When you need it dynamic, you can use ZK8. There is a new component <if>
what is dynamic.
It works with shadow elements in the dom.
Greetz chill.
Hello druiznyc,
Personally i would create a listbox or label dynamically in my controller depending on the size of the collection.
Another idea would be to create both components and set their visibility accordingly.
Finally you could use conditional evaluation as shown at the url below:
http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/ZUML/ConditionalEvaluation
Best Regards,
Darksu
Asked: 2015-09-29 17:45:36 +0800
Seen: 18 times
Last updated: Sep 30 '15
Is the listbox content size dynamic? I mean with this can it change size without leaving current page
chillworld ( 2015-09-29 17:59:04 +0800 )editChillwood, No once the page is created it would remain the same.
druiznyc ( 2015-09-29 18:16:48 +0800 )edit