Listbox

Components: listbox, listitem, listcell, listhead and listheader.

A list box is used to display a number of items in a list. The user may select an item from the list.

<window title="listbox demo" border="normal">
        <listbox id="box" width="250px">        
            <listhead sizable="true">            
                <listheader label="name" sort="auto"/>                
                <listheader label="gender" sort="auto"/>                
            </listhead>            
            <listitem>            
                <listcell label="Mary"/>                
                <listcell label="FEMALE"/>                
            </listitem>            
            <listitem>            
                <listcell label="John"/>                
                <listcell label="MALE"/>                
            </listitem>            
            <listitem>            
                <listcell label="Jane"/>                
                <listcell label="FEMALE"/>                
            </listitem>            
            <listitem>            
                <listcell label="Henry"/>                
                <listcell label="MALE"/>                
            </listitem>            
            <listfoot >            
                <listfooter><label value="This is footer1"/></listfooter>                
                <listfooter><label value="This is footer2"/></listfooter>                
            </listfoot>            
                </listbox>                
</window>

Listbox has two molds: default and select. If the select mold is used, the HTML's SELECT tag is generated instead.

Class Name

org.zkoss.zul.Listbox

Supported Child Components

Listitem Listhead Listfoot

Supported Events

Name

Event Type

onPaging

org.zkoss.zul.event.PagingEvent

Description: Notifies one of the pages of a multi-page component is

selected by the user.

Properties

Property

Description

Data Type

Default Value

align

Sets the horizontal alignment of the whole Listbox.

Val ue: left|center|right

java.lang.String

<null>

mod el

Sets the list model associated with this Listbox.

org.zkoss.zul.ListModel

<null>

pageSize

Sets the page size, aka., the number rows per page.

Note: Available only the paging mold

int

<null>

paginal

org.zkoss.zul.ext.Paginal

<null>

pre loadSize

Sets the number of rows to preload when receiving the rendering request from the client.

int

7

itemRenderer

Sets the renderer which is used to render each Listitem if getModel() is not null.

org .zkoss.zul.RowRenderer

<null>

maxlength

the maximal length of each item's label.

int

0(no effect)

multiple

Is multiple selections are allowed.

boolean

false

checkmark

Is the check mark shall be displayed in front of each item.

boolean

false

disable

Is this Listbox is disabled.

boolean

false

vflex

To grow and shrink vertical to fit their given space, so called vertial flexibility.

boolean

false

Methods

Name

Description

clone()

getIndexOfItem(Listitem)

Returns the index of the specified item, or -1 if not found.

ClearSelection()

Clears the selection.

addItemToSelection(Listitem)

Selects the given item, without deselecting any other items that are already selected..

appendItem(String,String)

Appends an item.

getItemAtIndex(int)

Returns the item at the specified index.

getSelectedIndex()

Returns the index of the selected item (-1 if no one is selected).

setSelectedIndex(int)

Deselects all of the currently selected items and selects the item with the given index.

GetItemCount()

Returns the number of items.

GetListHead()

Returns Listhead belonging to this Listbox, or null if no list headers at all.

GetListfoot()

Returns Listfoot belonging to this Listbox, or null if no list footers at all.

getOuterAttrs()

getPaging()

Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).

Sel ectAll()

Select all items.

ins ertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)

onInitRender()

Handles a private event, onInitRender.

onPaging()

Called when the onPaging event is received (from getPaginal()).

removeChild(org.zkoss.zk.ui.Component)

renderAll()

Renders all Listitem if not loaded yet, with getItemRenderer().

renderItems(java.util.Set)

renderItem(Listitem)

Renders the specified Row if not loaded yet, with getRowRenderer().

renderItems(java.util.Set)

Renders a set of specified rows.

setTabindex(int)

Sets the tab order of this component.

Currently, only the "select" mold supports this property.

getTabindex()

Returns the tab order of this component.

Currently, only the "select" mold supports this property.

Default: -1 (means the same as browser's default).

setItemRenderer(java.lang.String)

Sets the renderer by use of a class name.

toggleItemSelection(Listitem)

If the specified item is selected, it is deselected.

Inherited From