<basedatacombobox>
baseclass for a datacombobox

JavaScript: lz.basedatacombobox
An abstract class to create dropdown lists of selectable items. Define the look in a subclass. Also, a basedatacombobox_text must be declared in the subclass.
<canvas height="150">
     <include href="lz/floatinglist.lzx"/>
     
     <dataset name="items">
          <item value="item0">item 0</item>
          <item value="item1">item 1</item>
          <item value="item2">item 2</item>
          <item value="item3">item 3</item>
          <item value="item4">item 4</item>
          <item value="item5">item 5</item>
          <item value="item6">item 6</item>
          <item value="item7">item 7</item>
          <item value="item8">item 8</item>
          <item value="item9">item 9</item>
          <item value="item10">item 10</item>
          <item value="item11">item 11</item>
     </dataset>
     
     <class name="simplecombobox" extends="basedatacombobox" width="100">
          <attribute name="_cbtext" value="$once{this._text}"/>
          <attribute name="menuclassname" value="floatinglist" type="string"/>
          <view width="100%" height="20" focusable="false" bgcolor="#CCCCCC">
               <handler name="onclick">
                    lz.Focus.setFocus(this,false); 
                    classroot.toggle()
               </handler>
               <handler name="onmouseout">
                    this.setAttribute('bgcolor', 0xCCCCCC);
               </handler>
               <handler name="onmouseup">
                    this.setAttribute('bgcolor', 0xCCCCCC);
               </handler>
               <handler name="onmouseover">
                    this.setAttribute('bgcolor', 0xEEEEEE);
               </handler>
               <handler name="onmousedown">
                    this.setAttribute('bgcolor', 0xAAAAAA);
               </handler>
          </view>
          <text name="_text" width="${ parent.width - 19 }" x="7"/>
     </class>

     <simplecombobox id="cbox1" width="130" shownitems="6" defaulttext="Choose One..." itemdatapath="items:/item"/>
</canvas>
** Caveat: Combobox items will not update if the attributes that are mapped to textdatapath or valuedatapath change. To force the changes to update, call node.parentNode.replaceChild(node.cloneNode(true), node) where node is the dataelement of the list item. Don't forget to reset the seleciton on the list, as well.

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
defaulttext string String null read/write
  Default text to display before a selection is made. No default item is selected if defaulttext is set. Defaulttext is replaced with selected item's text.
ismenu expression any false read/write
  If true, the combobox will behave like a menu. "value" is ignored, and items will not remain selected. Selecting an item generates an onselect event
isopen expression any false read/write
  Indicates whether or not the popup list is showing.
itemclassname string String   read/write
  The name of the class for items in the floating list.
itemdatapath string String null read/write
  Datapath to items in list.
listattach string String bottom read/write
  Where the floatinglist should attach to its owner. Possible values: bottom, top, left, right. In the event of a canvas out-of-bounds, the floating list will attach in a visible location.
listwidth expression any null read/write
  Width of popup list, defaults to width of combobox view. During setup, the width of the floating list view might not yet be set, so this returns the expected width.
menuclassname string String   read/write
   
selected expression any null readonly
  Datapointer to selected item.
selectfirst expression any true read/write
  When true, the 1st item is selected oninit.
shownitems expression any 4 read/write
  Sets the height to the number of items to show in combobox popup list. Must be greater than 0.
statictext string String null read/write
  If set, this will always be displayed instead of selected item text. Behaves like a menu button. Also see defaulttext.
textdatapath string String text() read/write
  Datapath to text to display for items in list. See caveat.
value expression any null read/write
  The value of the selected item.
valuedatapath string String @value read/write
  Datapath to value for items in list. See caveat.

Attributes inherited from <basevaluecomponent>

type, value

Methods

doSetChanged()
basedatacombobox.doSetChanged(isChanged : Boolean);
Setter to set baseformitem to changed. Should be called by subclasses whenever a value is set. The first time this is called, the changed value is not set since it assumes subclasses are setting their initial value. This also updates the selected value in the combobox to reflect the new value (in case it was changed).
Parameter Name Type Description
isChanged Boolean true if changed, else false.

doSetValue()
basedatacombobox.doSetValue(value : String|Number, isinitvalue : Boolean, ignoreselection : Boolean);
Set value of combobox.
Parameter Name Type Description
value String|Number value to set.
isinitvalue Boolean true if value is an init value.
ignoreselection Boolean if true, selection won't be updated

getItemIndex()
basedatacombobox.getItemIndex(value : Object);
Get item's index by value. Returns
Parameter Name Type Description
value Object the value of the item to select.

getValue()
basedatacombobox.getValue();
Override getValue because we don't want to return this.text if this.value is null (this.text may be the defaulttext)

selectItem()
basedatacombobox.selectItem(value : Object);
Select an item by value.
Parameter Name Type Description
value Object the value of the item to select.

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

setOpen()
basedatacombobox.setOpen(open : Boolean);
Sets the open/close state of the popup list.
Parameter Name Type Description
open Boolean true to open the list, else false to close.

toggle()
basedatacombobox.toggle();
Toggles the open/close state of the popup list.

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
oncomboblur The equivalent for onblur for combobox.
oncombofocus The equivalent for onfocus for combobox.
onisopen Called when combobox opens or closes
onselect Event sent when an item is selected. Sends selected item.
onselected Event sent when an item is selected. Sends selected item.

Events inherited from <baseformitem>

onchanged, onvalue

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy