# Get heigh of component

orism
24 1 3

Hi,
I got some problems by getting the height of a component.

Example:
The component is a listbox with vflex="1".
My target is now to calculate the amount of listitem's that i can display within this listbox without scrolling.

In order to do that i will need the current height of the listbox .

Is there any event I can register in order to get the height of the component.

The only size event i get working is the ClientInfoEvent, this delivers only the total desktop heigth. But if i got nested elements this is not really good.

Is there any solution for this?

delete retag edit

jimmyshiau
4921 5
http://www.zkoss.org/

Hi, orism
If you don't want to display the listbox without scrolling.

you can try this sample

<zk>
<zscript><![CDATA[
String[] data = new String[5];
for (int j = 0; j < data.length; ++j) {
data = "option " + j;
}
ListModel strset = new ListModelList(data);
void change(int num) {
String[] data = new String;

for (int j = 0; j < data.length; ++j) {
data = "option " + j;
}
listbox.setModel(new ListModelList(data));
}
]]></zscript>
<button label='10' onClick='change(10)' />
<button label='20' onClick='change(20)' />
<button label='30' onClick='change(30)' />
<listbox id="listbox" width="200px" model="\${strset}">
</listbox>
</zk>



[hide preview]