Name

baselist — contains a group of baselistitems

Synopsis

LZX: baselist
JavaScript: baselist
Type: Class
Access: public
Topic: Components.Base Components
Declared in: lps/components/base/baselist.lzx

Description

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 replication attribute, LzLazyReplicationManager, and the example in list.
An abstract class which all list components should subclass.

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » basevaluecomponent » baseformitem » baselist

Known Subclasses

Known Direct Subclasses: basetabsbar, basetabslider, list, radiogroup

Details

Properties (5)

dataoption
<attribute name="dataoption" type="string" value="none" />
public var dataoption : String;
One of "lazy", "resize", "pooling", "none".
defaultselection
<attribute name="defaultselection" value="null" />
public var defaultselection;
The index of the default selected item, if none is provided via the selected="true" attribute on an item.
itemclassname
<attribute name="itemclassname" type="string" value="" />
public var itemclassname : String;
The name of the class for new items that will be created with addItem().
multiselect
<attribute name="multiselect" value="false" />
public var multiselect;
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
<attribute name="toggleselected" value="false" />
public var toggleselected;
When true, the first click on a list item selects it and the second click deselects it.

Methods (17)

addItem()
<method name="addItem" args="text, value" />
public function 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).
clearSelection()
<method name="clearSelection" />
public function clearSelection();
Clear the current selection.
getItem()
<method name="getItem" args="value" />
public function getItem(value : Object) : Object;
Find a particular item by value. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
getItemAt()
<method name="getItemAt" args="index" />
public function getItemAt(index : Number) : Object;
Get a particular item by its index. This method is not available with dataoption="lazy" or dataoption="resize" (use the data APIs instead).
getNumItems()
<method name="getNumItems" />
public function getNumItems() : Number;
Get the number of items in the list.
getSelection()
<method name="getSelection" />
public function getSelection() : Object;
Get the selection for the list. Normally this method returns views, but if dataoption="lazy" or dataoption="resize", it will return datapointers.
getText()
<method name="getText" />
public function getText() : Object;
Get text for the list.
getValue()
<method name="getValue" />
public function getValue() : Object;
Get the value(s) for the list.
moveSelection()
<method name="moveSelection" args="dir" />
public function moveSelection(dir : Number);
Move the selection to the next or previous view. This method not available with dataoption="lazy" or dataoption="resize"
removeItem()
<method name="removeItem" args="value" />
public function 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).
removeItemAt()
<method name="removeItemAt" args="index" />
public function 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).
select()
<method name="select" args="item" />
public function select(item : LzView);
Select an item.
selectItem()
<method name="selectItem" args="value" />
public function selectItem(value : Object);
Select an item by value. This method is not available with dataoption="lazy" or dataoption="resize".
selectItemAt()
<method name="selectItemAt" args="index" />
public function selectItemAt(index : Number);
Select an item by index.
selectNext()
<method name="selectNext" />
public function selectNext();
Move the selection to the next view. This method not available with dataoption="lazy" or dataoption="resize".
selectPrev()
<method name="selectPrev" />
public function selectPrev();
Move the selection to the previous view. This method not available with dataoption="lazy" or dataoption="resize".
setHilite()
<method name="setHilite" args="v" />
public function setHilite(v : LzView);
Set which view has the hilite.

Events (1)

onselect
<attribute name="onselect" />
public event 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.

LZX Synopsis

<class name="baselist" extends=" baseformitem ">
  <attribute name=" dataoption " type="string" value="none" />
  <attribute name=" defaultselection " value="null" />
  <attribute name=" itemclassname " type="string" value="" />
  <attribute name=" multiselect " value="false" />
  <attribute name=" toggleselected " value="false" />
  <method name=" addItem " args="text, value" />
  <method name=" clearSelection " />
  <method name=" getItem " args="value" />
  <method name=" getItemAt " args="index" />
  <method name=" getNumItems " />
  <method name=" getSelection " />
  <method name=" getText " />
  <method name=" getValue " />
  <method name=" moveSelection " args="dir" />
  <event name=" onselect " />
  <method name=" removeItem " args="value" />
  <method name=" removeItemAt " args="index" />
  <method name=" select " args="item" />
  <method name=" selectItem " args="value" />
  <method name=" selectItemAt " args="index" />
  <method name=" selectNext " />
  <method name=" selectPrev " />
  <method name=" setHilite " args="v" />
</class>

JavaScript Synopsis

public baselist extends  baseformitem  {
  public var dataoption  : String;
  public var defaultselection ;
  public var itemclassname  : String;
  public var multiselect ;
  public var toggleselected ;
  prototype public function addItem (text : String, value : Object);
  prototype public function clearSelection ();
  prototype public function getItem (value : Object) : Object;
  prototype public function getItemAt (index : Number) : Object;
  prototype public function getNumItems () : Number;
  prototype public function getSelection () : Object;
  prototype public function getText () : Object;
  prototype public function getValue () : Object;
  prototype public function moveSelection (dir : Number);
  prototype public event onselect ;
  prototype public function removeItem (value : Object);
  prototype public function removeItemAt (index : Number);
  prototype public function select (item : LzView);
  prototype public function selectItem (value : Object);
  prototype public function selectItemAt (index : Number);
  prototype public function selectNext ();
  prototype public function selectPrev ();
  prototype public function setHilite (v : LzView);
}