A List object represents a list of items that the user can select. The List class is derived from BaseList, which is a subclass of BaseFormItem. The class hierarchy for List is shown in Figure 2.15
Tables 2.12 and 2.13 present the attributes of the BaseList and List classes, respectively.
Name | Usage | Type | Default | Accessibility |
---|---|---|---|---|
dataoption | Tag and JS | string | none | read-write |
Description. One of “lazy”, “resize”, “pooling”, and “none”. | ||||
defaultselection | Tag and JS | Object | null | read-write |
Description. The index of the default selected item. | ||||
itemclassname | Tag and JS | string | read-write | |
Description. The name of the class to instantiate when the addItem method is invoked. | ||||
multiselect | Tag and JS | boolean | false | read-write |
Description. Indicates if multiple selection is allowed. | ||||
toggleselected | Tag and JS | boolean | false | read-write |
Description. Indicates whether or not a click toggles a selection. |
Name | Usage | Type | Default | Accessibility |
---|---|---|---|---|
autoscrollbar | Tag and JS | boolean | true | read-write |
Description. Indicates whether or not a scroll bar should be displayed when there are more items than the value of the shownitems attribute. | ||||
border_bottom | Tag and JS | number | read-write | |
Description. The size of the bottom border in pixels. | ||||
border_left | Tag and JS | number | none | read-write |
Description. The size of the left border in pixels. | ||||
border_right | Tag and JS | number | read-write | |
Description. The size of the right border in pixels. | ||||
border_top | Tag and JS | number | read-write | |
Description. The size of the top border in pixels. | ||||
bordersize | Tag and JS | number | 1 | read-write |
Description. The border size for this list in pixels. | ||||
minheight | Tag and JS | number | 24 | read-write |
Description. The minimum height of the list in pixels. | ||||
scrollable | Tag and JS | boolean | false | read-write |
Description. Indicates if this List is scrollable. | ||||
shownitems | Tag and JS | number | -1 | read-write |
Description. The number of items shown at a time. | ||||
spacing | Tag and JS | number | 0 | read-write |
Description. The spacing between items in the popup list in pixels. | ||||
tracking | Tag and JS | boolean | false | read-write |
Description. Indicates if mousedown tracking is enabled. |
Both BaseList and List define new methods. Here are methods defined by BaseList.
addItem(text, value)
Adds the specified text/value pair. The text argument is of type string and the value argument is of type Object.
clearSelection()
Clear the selection list.
getItem(value)
Return the specified value as Object; returns null if the combo box does not contain the specified value.
getItemAt(index)
Returns the item at the specified index.
getNumItems()
Returns the number of items in the list.
getSelection()
Returns the current selection.
getText()
Returns the displayed text.
getValue()
Returns the value for the list.
moveSelection(direction)
Moves the selection to the next view if direction is -1, or to the previous view if direction is 1.
removeItem(value)
Removes the specified item.
removeItemAt(index)
Removes the item at the specified index.
select(item)
Selects the specified item.
selectItem(value)
Selects an item by value.
selectItemAt(index)
Selects the item at the specified index.
selectNext()
Select the next item.
selectPrev()
Select the previous item.
setHilite(view)
Highlights the specified view.
The following are methods added in the List class:
ensureItemInView(item)
Scrolls the list so that the specified item will appear at the top of the list.
select(view)
Selects the specified view.
Listing 2.12 shows an LZX application that uses a List object.
<canvas height="150"> <list shownitems="3"> <textlistitem>Jazz</textlistitem> <textlistitem>Pop</textlistitem> <textlistitem>Heavy Metal</textlistitem> <textlistitem>Fusion</textlistitem> <textlistitem>Rock</textlistitem> </list> </canvas> |
Use this URL to compile and run the LZX application in Listing 2.12.
http://localhost:8080/lps-4.0.x/app02/listTest1.lzx
Figure 2.16 shows the generated application.
Note that the list in Figure 2.16 has five items but is only showing three items because the showitems attribute of the list was given the value of 3.