# Issue disabling a listbox

Luuzz
109 1

Hello Everybody
I am new here ant i have few problems using listbox component.
In fact, i want to disable a listbox, but when i do, it becomes invisible.

delete retag edit

## 7 Replies

937 2 12

Hey there,

So, in other words, you want the read-only feature for listbox?
So that when the listbox it´s read-only, the user can see the selected item text, but can´t change it?

ansancle
317 9

use disabled="true"

Ex..
<listbox disabled="true" rows="1" mold="select">
<listitem label="option1"/>
<listitem label="option2"/>
<listitem label="option3"/>
</listbox>

Luuzz
109 1

I'm glad to get feedback so quickly !!
I have tried to use disabled="true" but this doesn't work, the listbox gets simply invisible.
Maybe this is because i didn't use rows="1" and mold="select". I'm gonna try this and let you know.

Luuzz
109 1

I tried this and it's working great !
But i still don't understand why it doesn't work without these two attributes ...
Thank you all.

ansancle
317 9

You will get some different behavior out of the listbox depending upon which "mold" you are in. mold="select" means you have a single row drop-down list. In this case you don't need to specify the number of rows since it is implicit. If mold does not equal select then you do need to tell it how many rows you want the listbox to show. For example :

	<listbox width="250px" rows="5"/>

In this case it will show 5 rows.

If you do not specify mold="select" and you do not give it a number of rows the listbox will not show up.

I recommend you use the live demo to see sample code and test out different things to see what works and what does not, this tool is invaluable.

http://www.zkoss.org/zkdemo/userguide/

hkn
246 3

Hello,

I have a quite similar problem. First I tried to disable the listbox in total by lbUsersTest.setDisabled(true) but that doesn't work. But I can disable the rows, respective <z:listitem> by looping over all items of the listbox and disable each of them. But my expectation of setDisable(true|false) is to disable a component in total and all its childs so that all events - specially selection clicks - are deactivated.
Am I right with my expectation?

As described before by someone else <...mold="select" > setDisabled() works but I loose all my columns, just one is kept !

Has anyone out there found a solution??

Thanks

<z:listbox width="99%" id="lbUsersTest" height="100px" disabled="true">
<z:listitem disabled="true">
<z:listcell label="11"/><z:listcell label="12"/><z:listcell label="13"/>
</z:listitem>
<z:listitem>
<z:listcell label="21"/><z:listcell label="22"/><z:listcell label="23"/>
</z:listitem>
</z:listbox>

henrichen
3869 2

Please post to feature request. Thanks.

[hide preview]