<baselist>

contains a group of baselistitems

JavaScript: baselist

Extends Baseformitem

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="70">
 <dataset name="items">
    <item>one</item>
    <item>two</item>
    <item>three</item>
  </dataset>

  <class name="myitem" extends="baselistitem"
         bgcolor="${selected ? yellow : white}">
     <attribute name="text" type="text"/>
     <method name="applydata" args="d">
         setAttribute('text', d);
     </method>
     <text text="${parent.text}"/>
  </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 pooling 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 lazy replication attribute, LzLazyReplicationManager, and the example in list.
Attributes
Name Usage Type (Tag) Type (JS) Default Category
dataoption Tag & JS string String none setter
 

One of "lazy", "resize", "pooling", "none".


defaultselection Tag & JS expression any null setter
 

The index of the default selected item, if none is provided via the selected="true" attribute on an item.


itemclassname Tag & JS string String   setter
 

The name of the class for new items that will be created with addItem().


multiselect Tag & JS expression any false setter
 

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 Tag & JS expression any false setter
 

When true, the first click on a list item selects it and the second click deselects it.



Attributes inherited from Basecomponent

doesenter, enabled, hasdefault, isdefault, style, styleable, text

Attributes inherited from Baseformitem

changed, ignoreform, onchanged, onvalue, rollbackvalue, submit, submitname

Attributes inherited from Basevaluecomponent

value

Attributes inherited from Node

class, classroot, cloneManager, datapath, id, ignoreAttribute, ignoreplacement, immediateparent, initstage, name, nodeLevel, onconstruct, oninit, parent, placement, subnodes

Attributes inherited from View

aaactive, aadescription, aaname, aasilent, aatabindex, align, bgcolor, clickable, clickregion, clip, cursor, defaultplacement, fgcolor, focusable, focustrap, font, fontsize, fontstyle, frame, framesloadratio, hassetheight, hassetwidth, height, layout, loadratio, mask, onblur, onclick, ondata, ondblclick, onfocus, onkeydown, onkeyup, onmousedown, onmouseout, onmouseover, onmouseup, onselect, opacity, options, pixellock, play, resource, resourceheight, resourcewidth, rotation, selectiontype, showhandcursor, source, stretches, subviews, totalframes, unstretchedheight, unstretchedwidth, valign, visible, width, x, xoffset, y, yoffset


Methods

addItem()
baselist.addItem(text, value)

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).

Parameters
Name Type Desc
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)

Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).

Parameters
Name Type Desc
value Object the value for the item to get.
Returns
Type Desc
Object the item found, or null, if not.


getItemAt()
baselist.getItemAt(index)

Get a particular item by its index. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).

Parameters
Name Type Desc
index Number the index for the item to get.
Returns
Type Desc
Object the item found, or null, if not.


getNumItems()
baselist.getNumItems()

Get the number of items in the list.

Returns
Type Desc
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 Desc
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 Desc
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 Desc
Object null if no selection, a single value if single select, or an array of values if multiselect.


moveSelection()
baselist.moveSelection(dir)

Move the selection to the next or previous view. This method not available with dataoption="lazy" or dataoption="resize"

Parameters
Name Type Desc
dir Number -1: move up, 1: move down


removeItem()
baselist.removeItem(value)

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).

Parameters
Name Type Desc
value Object the value of the item to remove.


removeItemAt()
baselist.removeItemAt(index)

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).

Parameters
Name Type Desc
index Number the index of the item to remove.


select()
baselist.select(item)

Select an item.

Parameters
Name Type Desc
item LzView the view to select (may be an array when multiselect == true)


selectItem()
baselist.selectItem(value)

Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".

Parameters
Name Type Desc
value Object the value of the item to select.


selectItemAt()
baselist.selectItemAt(index)

Select an item by index.

Parameters
Name Type Desc
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)

Set which view has the hilite.

Parameters
Name Type Desc
v LzView the view to hilite.


Methods inherited from basecomponent

doEnterDown, doEnterUp, doSpaceDown, doSpaceUp, setStyle, setTint, updateDefault

Methods inherited from baseformitem

applyData, commit, findForm, init, rollback, setChanged, setValue, toXML, updateData

Methods inherited from basevaluecomponent

getValue

Methods inherited from LzNode

animate, applyConstraint, childOf, completeInstantiation, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, lookupSourceLocator, searchImmediateSubnodes, searchSubnodes, setAttribute, setDatapath, setID, setName, setOption

Methods inherited from LzView

addProxyPolicy, addSubview, bringToFront, construct, containsPt, getAttributeRelative, getBounds, getColor, getColorTransform, getContextMenu, getCurrentTime, getDepthList, getHeight, getID3, getMouse, getPan, getTotalTime, getVolume, getWidth, measureHeight, measureWidth, play, releaseLayouts, removeProxyPolicy, searchParents, searchSubviews, seek, sendBehind, sendInFrontOf, sendToBack, setAAActive, setAADescription, setAAName, setAASilent, setAATabIndex, setAlign, setAttributeRelative, setBGColor, setClickable, setColor, setColorTransform, setContextMenu, setCursor, setHeight, setLayout, setOpacity, setPan, setPlay, setResource, setResourceNumber, setRotation, setShowHandCursor, setSource, setValign, setVisible, setVolume, setWidth, setX, setY, shouldYieldFocus, stop, stretchResource, unload, updateResourceSize


Events

Events inherited from LzNode

onconstruct, ondata, oninit

Events inherited from LzView

onaddsubresource, onaddsubview, onblur, onclick, ondblclick, onerror, onfocus, onframe, onheight, onlastframe, onload, onmousedown, onmousedragin, onmousedragout, onmouseout, onmouseover, onmouseup, onmouseupoutside, onopacity, onplay, onremovesubview, onstop, ontimeout, onwidth, onx, ony