0

Dynamic listbox with one listitem as label

asked 2015-09-29 17:45:36 +0800

druiznyc gravatar image druiznyc
1 2

updated 2015-09-29 17:48:58 +0800

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

delete flag offensive retag edit

Comments

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

Chillwood, No once the page is created it would remain the same.

druiznyc ( 2015-09-29 18:16:48 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-09-30 06:19:37 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

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.

link publish delete flag offensive edit
1

answered 2015-09-29 18:01:02 +0800

Darksu gravatar image Darksu
1991 1 4

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

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: 2015-09-29 17:45:36 +0800

Seen: 18 times

Last updated: Sep 30 '15

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