Zimlet JavaScript API Reference - DwtSelect

Class DwtSelect


Extends DwtButton TODO: add option to keep options sorted by display text.

Widget to replace the native select element.

Note: Currently this does not support multiple selection.

Defined in: DwtSelect.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
DwtSelect(params, layout)
Creates a select element.
Method Summary
Method Attributes Method Name and Description
 
Adds a change listener.
 
addOption(option, selected, value, image)
Adds an option.
 
Clears the options.
 
Disables the select.
 
Enables the select.
 
enableOption(value, enabled)
Enables or disables an option.
 
Gets the index for a given value.
 
Gets the select name.
 
Gets the option count.
 
Gets the options.
 
getOptionWithHandle(optionHandle)
Gets the option .
 
getOptionWithValue(optionValue)
Gets the option for a given value.
 
Gets the selected option index.
 
Gets the selected option.
 
Gets the selected value.
 
removeOption(option)
Removes an option.
 
Removes an option based on its value.
 
rename(value, newValue)
Renames an option.
 
setName(name)
Sets the select name.
 
setSelected(optionHandle)
Sets the option as the selected option.
 
setSelectedOption(optionObj)
Sets the selected option.
 
setSelectedValue(optionValue)
Sets the selected value.
 
size()
Gets the count of options.
Class Detail
DwtSelect(params, layout)
Creates a select element.
Parameters:
{hash} params
a hash of parameters
{DwtComposite} params.parent
the parent widget
{array} params.options
a list of options. This can be either an array of DwtSelectOption or {String} objects.
{string} params.className
the CSS class
{constant} params.posStyle
the positioning style (see DwtControl)
{boolean} layout Optional, Default: true
layout to use: DwtMenu.LAYOUT_STACK, DwtMenu.LAYOUT_CASCADE or DwtMenu.LAYOUT_SCROLL. A value of [true] defaults to DwtMenu.LAYOUT_CASCADE and a value of [false] defaults to DwtMenu.LAYOUT_STACK.
Method Detail
addChangeListener(listener)
Adds a change listener.
Parameters:
{AjxListener} listener
the listener

{number} addOption(option, selected, value, image)
Adds an option.
Parameters:
{string|DwtSelectOption|DwtSelectOptionData} option
a {String} for the option value or the DwtSelectOption object
{boolean} selected Optional
indicates whether option should be the selected option
{Object} value
if the option parameter is a DwtSelectOption, this will override the value already set in the option.
{String} image
(optional)
Returns:
{number} a handle to the newly added option TODO: support adding at an index

clearOptions()
Clears the options.

disable()
Disables the select.

enable()
Enables the select.

enableOption(value, enabled)
Enables or disables an option.
Parameters:
{Object} value
the value of the option to enable/disable
{boolean} enabled
if true, enable the option

{number} getIndexForValue(value)
Gets the index for a given value.
Parameters:
{Object} value
the value
Returns:
{number} the index

{string} getName()
Gets the select name.
Returns:
{string} the name

{number} getOptionCount()
Gets the option count.
Returns:
{number} the option count

{AjxVector} getOptions()
Gets the options.
Returns:
{AjxVector} a vector of DwtSelectOption objects

{DwtSelectOption} getOptionWithHandle(optionHandle)
Gets the option .
Parameters:
{number} optionHandle
a handle to the option
Returns:
{DwtSelectOption} the option
See:
#addOption

{DwtSelectOption} getOptionWithValue(optionValue)
Gets the option for a given value.
Parameters:
{Object} optionValue
the value
Returns:
{DwtSelectOption} the option

{number} getSelectedIndex()
Gets the selected option index.
Returns:
{number} the selected option index

{DwtSelectOption} getSelectedOption()
Gets the selected option.
Returns:
{DwtSelectOption} the selected option

{Object} getValue()
Gets the selected value.
Returns:
{Object} the value

{number} removeOption(option)
Removes an option.
Parameters:
{DwtSelectOption} option
option to remove
Returns:
{number} index of the option that was removed, or -1 if there was an error

{number} removeOptionWithValue(value)
Removes an option based on its value.
Parameters:
{string} value
value of the option to remove
Returns:
{number} index of the option that was removed, or -1 if there was an error

rename(value, newValue)
Renames an option.
Parameters:
{Object} value
the value of the option to rename
{string} newValue
the new display value

setName(name)
Sets the select name.
Parameters:
{string} name
the name

setSelected(optionHandle)
Sets the option as the selected option.
Parameters:
{number} optionHandle
a handle to the option
See:
#addOption

setSelectedOption(optionObj)
Sets the selected option.
Parameters:
{Object} optionObj
the object

setSelectedValue(optionValue)
Sets the selected value.
Parameters:
{Object} optionValue
the value of the option to select

{number} size()
Gets the count of options.
Returns:
{number} the count

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:29 GMT-0400 (EDT)