Home

# Class goog.ui.Select

A selection control. Extends {@link goog.ui.MenuButton} by composing a menu with a selection model, and automatically updating the button's caption based on the current selection. Select fires the following events: CHANGE - after selection changes.

extends goog.ui.MenuButton

Instance Method Summary
| `addItem((goog.ui.MenuItem|goog.ui.MenuSeparator|null) item)` Adds a new menu item at the end of the menu.
| `addItemAt((goog.ui.MenuItem|goog.ui.MenuSeparator|null) item, number index)` Adds a new menu item at a specific index in the menu.
| `createSelectionModel_(?goog.ui.Component= opt_component)` Creates a new selection model and sets up an event listener to handle {@link goog.events.EventType.SELECT} events dispatched by it.
| `decorateInternal(?Element element)` Decorates the given element with this control. Overrides the superclass implementation by initializing the default caption on the select button.
| `disposeInternal()` Disposes of the component. Calls {@code exitDocument}, which is expected to remove event handlers and clean up the component. Propagates the call to the component's children, if any. Removes the component's DOM from the document unless it was decorated.
| `enterDocument()` Configures the component after its DOM has been rendered, and sets up event handling. Overrides {@link goog.ui.MenuButton#enterDocument}.
| `getDefaultCaption() ⇒ ?goog.ui.ControlContent` Returns the default caption to be shown when no option is selected.
| `getSelectedIndex() ⇒ number` Returns the index of the currently selected option.
| `getSelectedItem() ⇒ ?goog.ui.MenuItem` Returns the currently selected option.
| `getSelectionModel() ⇒ ?goog.ui.SelectionModel`
| `handleMenuAction(?goog.events.Event e)` Handles {@link goog.ui.Component.EventType.ACTION} events dispatched by the menu item clicked by the user. Updates the selection model, calls the superclass implementation to hide the menu, stops the propagation of the event, and dispatches an ACTION event on behalf of the select control itself. Overrides {@link goog.ui.MenuButton#handleMenuAction}.
| `handleSelectionChange(?goog.events.Event e)` Handles {@link goog.events.EventType.SELECT} events raised by the selection model when the selection changes. Updates the contents of the select button.
| `listenToSelectionModelEvents_()` Subscribes to events dispatched by the selection model.
| `removeItem(?goog.ui.MenuItem item)` Removes an item from the menu and disposes it.
| `removeItemAt(number index)` Removes a menu item at a given index in the menu and disposes it.
| `setCorrectAriaRole_((goog.ui.MenuItem|goog.ui.MenuSeparator|null) item)` Sets the correct ARIA role for the menu item or separator.
| `setDefaultCaption(?goog.ui.ControlContent caption)` Sets the default caption to the given string or DOM structure.
| `setMenu(?goog.ui.Menu menu) ⇒ (goog.ui.Menu|null|undefined)` Replaces the menu currently attached to the control (if any) with the given argument, and updates the selection model. Does nothing if the new menu is the same as the old one. Overrides {@link goog.ui.MenuButton#setMenu}.
| `setOpen(boolean open)` Opens or closes the menu. Overrides {@link goog.ui.MenuButton#setOpen} by highlighting the currently selected option on open.
| `setSelectedIndex(number index)` Selects the option at the specified index, or clears the selection if the index is out of bounds.
| `setSelectedItem(?goog.ui.MenuItem item)` Selects the specified option (assumed to be in the select menu), and deselects the previously selected option, if any. A null argument clears the selection.
| `setValue(<Any Type> value)` Selects the first option found with an associated value equal to the argument, or clears the selection if no such option is found. A null argument also clears the selection. Overrides {@link goog.ui.Button#setValue}.
| `updateCaption()` Updates the caption to be shown in the select button. If no option is selected and a default caption is set, sets the caption to the default caption; otherwise to the empty string.