<baselist>
An abstract class which all list components should subclass.

JavaScript: lz.baselist

This class is a container for a group of baselistitems. To use baselist, baselistitem must be subclassed to provide a visual representation of the list item. It supports single select by default. Set multiselect to true to allow multiple selection (shift-click for a range, control-click for an arbitrary set).

Contained list items may be declared inside the list, such as:

<canvas height="100">
              <baselist layout="axis:y;spacing:2">
                <baselistitem height="15" width="25" bgcolor="${selected ? 0xffff00 : 0x0000ff}"/>
                <baselistitem height="15" width="50" bgcolor="${selected ? 0xffff00 : 0x0000ff}"/>
                <baselistitem height="15" width="100" bgcolor="${selected ? 0xffff00 : 0x0000ff}"/>
              </baselist>
              <text y="70">Click bar to select it.</text>
            </canvas>

or replicated from data:

<canvas height="90">
             <dataset name="items">
                <item>one</item>
                <item>two</item>
                <item>three</item>
              </dataset>
            
              <class name="myitem" extends="baselistitem" bgcolor="${selected ? 0xffff00 : 0xffffff}">
                 <text text="${parent.value}"/>
              </class>
            
              <baselist layout="axis:y; spacing:2">
                <myitem datapath="items:/item/text()"/>
              </baselist>
              <text y="70">Click on a number to select it.</text>
             </canvas>

Optimizing Lists

If your lists represent data from a datapath, there are two optimizations that you may want to consider:

pooling
If you will be changing the data that is represented by the list after it has been created, you can set dataoption="pooling". For more about pooling see the datapath ??? attribute and the example in list.
lazy
If there are more items in the list than will be visible and all list items are the same size (for example, in a scrolling list or combobox), you should set dataoption="lazy". For more about lazy replication see the datapath ??? attribute, LzLazyReplicationManager, and the example in list.

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
dataoption string String none read/write
  One of "lazy", "resize", "pooling", "none".
defaultselection expression any null read/write
  The index of the default selected item, if none is provided via the selected="true" attribute on an item.
itemclassname string String   read/write
  The name of the class for new items that will be created with addItem().
multiselect expression any false read/write
  If multiselect is true, multiple items may be selected. When the shift key is down, a range of items is selected. When the control key is down, any item may be added to the selection.
toggleselected expression any false read/write
  When true, the first click on a list item selects it and the second click deselects it.

Attributes inherited from <basevaluecomponent>

type, value

Methods

addItem()
baselist.addItem(text : String, value : Object);
Add an item to the end of the list. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
Parameter Name Type Description
text String the text for the item.
value Object the value for the item.

clearSelection()
baselist.clearSelection();
Clear the current selection.

getItem()
baselist.getItem(value : Object);
Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
Parameter Name Type Description
value Object the value for the item to get.
Returns Type Description
  Object the item found, or null, if not.

getItemAt()
baselist.getItemAt(index : Number);
Get a particular item by its index. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
Parameter Name Type Description
index Number the index for the item to get.
Returns Type Description
  Object the item found, or null, if not.

getNumItems()
baselist.getNumItems();
Get the number of items in the list.
Returns Type Description
  Number number of items.

getSelection()
baselist.getSelection();
Get the selection for the list. Normally this method returns views, but if dataoption="lazy" or dataoption="resize", it will return datapointers.
Returns Type Description
  Object null if no selection, an item if single select (default), or an array of items if multiselect.

getText()
baselist.getText();
Get text for the list.
Returns Type Description
  Object null if no selection, a string if single select, or an array of strings if multiselect.

getValue()
baselist.getValue();
Get the value(s) for the list.
Returns Type Description
  Object null if no selection, a single value if single select, or an array of values if multiselect.

moveSelection()
baselist.moveSelection(dir : Number);
Move the selection to the next or previous view. This method not available with dataoption="lazy" or dataoption="resize"
Parameter Name Type Description
dir Number -1: move up, 1: move down

removeAllItems()
baselist.removeAllItems();
Removes all items from the list.

removeItem()
baselist.removeItem(value : Object);
Find the first item with the specified value and remove it from the list. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
Parameter Name Type Description
value Object the value of the item to remove.

removeItemAt()
baselist.removeItemAt(index : Number);
Find the item at the specified index and remove it from the list. This method is not available with dataoption="lazy" or dataoption="resize" (use data APIs instead).
Parameter Name Type Description
index Number the index of the item to remove.

select()
baselist.select(item : lz.view);
Select an item.
Parameter Name Type Description
item lz.view the view to select (may be an array when multiselect == true)

selectItem()
baselist.selectItem(value : Object);
Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".
Parameter Name Type Description
value Object the value of the item to select.

selectItemAt()
baselist.selectItemAt(index : Number);
Select an item by index.
Parameter Name Type Description
index Number the index of the item to select.

selectNext()
baselist.selectNext();
Move the selection to the next view. This method not available with dataoption="lazy" or dataoption="resize".

selectPrev()
baselist.selectPrev();
Move the selection to the previous view. This method not available with dataoption="lazy" or dataoption="resize".

setHilite()
baselist.setHilite(v : lz.view);
Set which view has the hilite.
Parameter Name Type Description
v lz.view the view to hilite.

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onitemclassname This event is triggered whenever the itemclassname attribute changes.
onselect This event is triggered whenever the user makes a selection it may used as a script in the tag or as an event method.

Events inherited from <baseformitem>

onchanged, onvalue

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy