dijit/form/ComboBoxMixin (version 1.10)

dijit/_HasDropDown, dijit/form/_AutoCompleterMixin

Summary

Provides main functionality of ComboBox widget

Usage

var foo = new ComboBoxMixin();
dijit/form/_SearchMixin

See the dijit/form/ComboBoxMixin reference documentation for more information.

Property Summary

  • _aroundNodeThe node to display the popup around.
  • _arrowWrapperNodeWill set CSS class dijitUpArrow, dijitDownArrow, dijitRightArrow etc. on this node depending on where the drop down is set to be positioned.
  • _buttonNodeThe button/icon/node to click to display the drop down.
  • _focusManager
  • _popupStateNodeThe node to set the aria-expanded class on.
  • _stopClickEventsWhen set to false, the click events will not be stopped, in case you want to use them in your subclass
  • autoCompleteIf user types in a partial string, and then tab out of the <input> box, automatically copy the first entry displayed in the drop down list to the <input> field
  • autoWidthSet to true to make the drop down at least as wide as this widget.
  • baseClass
  • cssStateNodes
  • dropDownThe widget to display as a popup.
  • dropDownPositionThis variable controls the position of the drop down.
  • fetchPropertiesMixin to the store's fetch.
  • forceWidthSet to true to make the drop down exactly as wide as this widget.
  • hasDownArrowSet this textbox to have a down arrow button, to display the drop down list.
  • highlightMatchOne of: "first", "all" or "none".
  • ignoreCaseSet true if the query should ignore case when matching possible items
  • itemThis is the item returned by the dojo/store/api/Store implementation that provides the data for this ComboBox, it's the currently selected item.
  • labelAttrThe entries in the drop down list come from this attribute in the dojo.data items.
  • labelTypeSpecifies how to interpret the labelAttr in the data store items.
  • listAlternate to specifying a store.
  • maxHeightThe max height for our dropdown.
  • pageSizeArgument to data provider.
  • queryA query that can be passed to store to initially filter the items.
  • queryExprThis specifies what query is sent to the data store, based on what the user has typed.
  • searchAttrSearch for items in the data store where this attribute (in the item) matches what the user typed
  • searchDelayDelay in milliseconds between when user types something and we start searching based on that value
  • storeReference to data provider object used by this ComboBox.
  • templateString

Method Summary

Event Summary

  • _onBlur() Called magically when focus has shifted away from this widget and it's dropdown
  • _onDropDownClick(e)
  • _onDropDownMouseDown(e) Callback when the user mousedown/touchstart on the arrow icon.
  • _onDropDownMouseUp(e) Callback on mouseup/touchend after mousedown/touchstart on the arrow icon.
  • _onKey(e) Callback when the user presses a key while focused on the button node
  • _onKeyUp()
  • onSearch(results,query,options) Callback when a search completes.

Properties

_aroundNode
Defined by: dijit/_HasDropDown

The node to display the popup around. Can be set via a data-dojo-attach-point assignment. If missing, then domNode will be used.

_arrowWrapperNode
Defined by: dijit/_HasDropDown

Will set CSS class dijitUpArrow, dijitDownArrow, dijitRightArrow etc. on this node depending on where the drop down is set to be positioned. Can be set via a data-dojo-attach-point assignment. If missing, then _buttonNode will be used.

_buttonNode
Defined by: dijit/_HasDropDown

The button/icon/node to click to display the drop down. Can be set via a data-dojo-attach-point assignment. If missing, then either focusNode or domNode (if focusNode is also missing) will be used.

_focusManager
Defined by: dijit/_FocusMixin
_popupStateNode
Defined by: dijit/_HasDropDown

The node to set the aria-expanded class on. Also sets popupActive class but that will be removed in 2.0. Can be set via a data-dojo-attach-point assignment. If missing, then focusNode or _buttonNode (if focusNode is missing) will be used.

_stopClickEvents
Defined by: dijit/_HasDropDown

When set to false, the click events will not be stopped, in case you want to use them in your subclass

autoComplete

If user types in a partial string, and then tab out of the <input> box, automatically copy the first entry displayed in the drop down list to the <input> field

autoWidth
Defined by: dijit/_HasDropDown

Set to true to make the drop down at least as wide as this widget. Set to false if the drop down should just be its default width.

baseClass
cssStateNodes
dropDown
Defined by: dijit/_HasDropDown

The widget to display as a popup. This widget must be defined before the startup function is called.

dropDownPosition
Defined by: dijit/_HasDropDown

This variable controls the position of the drop down. It's an array of strings with the following values:

  • before: places drop down to the left of the target node/widget, or to the right in the case of RTL scripts like Hebrew and Arabic
  • after: places drop down to the right of the target node/widget, or to the left in the case of RTL scripts like Hebrew and Arabic
  • above: drop down goes above target node
  • below: drop down goes below target node

The list is positions is tried, in order, until a position is found where the drop down fits within the viewport.

fetchProperties

Mixin to the store's fetch. For example, to set the sort order of the ComboBox menu, pass:

{ sort: [{attribute:"name",descending: true}] }

To override the default queryOptions so that deep=false, do:

{ queryOptions: {ignoreCase: true, deep: false} }
forceWidth
Defined by: dijit/_HasDropDown

Set to true to make the drop down exactly as wide as this widget. Overrides autoWidth.

hasDownArrow

Set this textbox to have a down arrow button, to display the drop down list. Defaults to true.

highlightMatch

One of: "first", "all" or "none".

If the ComboBox/FilteringSelect opens with the search results and the searched string can be found, it will be highlighted. If set to "all" then will probably want to change queryExpr parameter to '${0}'

Highlighting is only performed when labelType is "text", so as to not interfere with any HTML markup an HTML label might contain.

ignoreCase

Set true if the query should ignore case when matching possible items

item

This is the item returned by the dojo/store/api/Store implementation that provides the data for this ComboBox, it's the currently selected item.

labelAttr

The entries in the drop down list come from this attribute in the dojo.data items. If not specified, the searchAttr attribute is used instead.

labelType

Specifies how to interpret the labelAttr in the data store items. Can be "html" or "text".

list

Alternate to specifying a store. Id of a dijit/form/DataList widget.

maxHeight
Defined by: dijit/_HasDropDown

The max height for our dropdown. Any dropdown taller than this will have scrollbars. Set to 0 for no max height, or -1 to limit height to available space in viewport

pageSize

Argument to data provider. Specifies maximum number of search results to return per query

query

A query that can be passed to store to initially filter the items. ComboBox overwrites any reference to the searchAttr and sets it to the queryExpr with the user's input substituted.

queryExpr

This specifies what query is sent to the data store, based on what the user has typed. Changing this expression will modify whether the results are only exact matches, a "starting with" match, etc. ${0} will be substituted for the user text. * is used for wildcards. ${0}* means "starts with", *${0}* means "contains", ${0} means "is"

searchAttr

Search for items in the data store where this attribute (in the item) matches what the user typed

searchDelay

Delay in milliseconds between when user types something and we start searching based on that value

store

Reference to data provider object used by this ComboBox.

Should be dojo/store/api/Store, but dojo/data/api/Read supported for backwards compatibility.

templateString

Methods

_abortQuery()
_announceOption(node)

a11y code that puts the highlighted option in the textbox. This way screen readers will know what is happening in the menu.

Parameter Type Description
node Node
_autoCompleteText(text)

Fill in the textbox with the first item from the drop down list, and highlight the characters that were auto-completed. For example, if user typed "CA" and the drop down list appeared, the textbox would be changed to "California" and "ifornia" would be highlighted.

Parameter Type Description
text String
_escapeHtml(str)
Parameter Type Description
str String
Returns:undefined
_getCaretPos(element)
Parameter Type Description
element DomNode
Returns:undefined
_getMenuLabelFromItem(item)
Parameter Type Description
item Item
Returns:object
_getValueField()

Helper for postMixInProperties() to set this.value based on data inlined into the markup. Returns the attribute name in the item (in dijit/form/_ComboBoxDataStore) to use as the value.

Returns:undefined
_openResultList(results,query,options)

Callback when a search completes.

  1. generates drop-down list and calls _showResultList() to display it
  2. if this result list is from user pressing "more choices"/"previous choices" then tell screen reader to announce new option
Parameter Type Description
results Object
query Object
options Object
_patternToRegExp(pattern)

Helper function to convert a simple pattern to a regular expression for matching.

Returns a regular expression object that conforms to the defined conversion rules. For example:

  • ca -> /^ca.$/
  • ca -> /^.ca.$/
  • c\a -> /^.c*a.*$/
  • c\a? -> /^.c*a..*$/

and so on.

Parameter Type Description
pattern dojo/string

A simple matching pattern to convert that follows basic rules:

    • Means match anything, so ca* means match anything starting with ca
  • ? Means match single character. So, b?b will match to bob and bab, and so on.
  • \ is an escape character. So for example, * means do not treat as a match, but literal character .

To use a \ as a character in the string, it must be escaped. So in the pattern it should be represented by \ to be treated as an ordinary \ character instead of an escape.

Returns:instance
_processInput(evt)

Handles input (keyboard/paste) events

Parameter Type Description
evt Event
_selectOption(target)

Menu callback function, called when an item in the menu is selected.

Parameter Type Description
target DomNode
_setBlurValue()
_setCaretPos(element,location)
Parameter Type Description
element DomNode
location Number
_setDisabledAttr(value)
Parameter Type Description
value Boolean
_setHasDownArrowAttr(val)
Parameter Type Description
val Boolean
_setItemAttr(item,priorityChange,displayedValue)

Set the displayed valued in the input box, and the hidden value that gets submitted, based on a dojo.data store item.

Users shouldn't call this function; they should be calling set('item', value)

Parameter Type Description
item item
priorityChange Boolean
Optional
displayedValue String
Optional
_setListAttr(list)
Parameter Type Description
list undefined
_setStoreAttr(store)
Parameter Type Description
store undefined
_setValueAttr(value,priorityChange,displayedValue,item)

Hook so set('value', value) works.

Sets the value of the select.

Parameter Type Description
value String
priorityChange Boolean
Optional
displayedValue String
Optional
item item
Optional
_showResultList()
_startSearch(key)

Starts a search for elements matching key (key=="" means to return all items), and calls _openResultList() when the search completes, to display the results.

Parameter Type Description
key String
_startSearchAll()
_startSearchFromInput()
buildRendering()
Defined by dijit/_HasDropDown
closeDropDown(focus)
Defined by dijit/_HasDropDown

Closes the drop down on this widget

Parameter Type Description
focus Boolean

If true, refocuses the button widget

destroy()
Defined by dijit/_HasDropDown
doHighlight(label,find)

Highlights the string entered by the user in the menu. By default this highlights the first occurrence found. Override this method to implement your custom highlighting.

Parameter Type Description
label String
find String
Returns:undefined
dropDownClass()

Dropdown widget class used to select a date/time. Subclasses should specify this.

isLoaded()
Defined by dijit/_HasDropDown

Returns true if the dropdown exists and it's data is loaded. This can be overridden in order to force a call to loadDropDown().

Returns:boolean
labelFunc(item,store)

Computes the label to display based on the dojo.data store item.

Parameter Type Description
item Object

The item from the store

store dojo/store/api/Store

The store.

Returns:any | undefined

The label that the ComboBox should display

loadAndOpenDropDown()
Defined by dijit/_HasDropDown

Creates the drop down if it doesn't exist, loads the data if there's an href and it hasn't been loaded yet, and then opens the drop down. This is basically a callback when the user presses the down arrow button to open the drop down.

Returns:Deferred | instance

Deferred for the drop down widget that fires when drop down is created and loaded

loadDropDown(loadCallback)
Defined by dijit/_HasDropDown

Creates the drop down if it doesn't exist, loads the data if there's an href and it hasn't been loaded yet, and then calls the given callback.

Parameter Type Description
loadCallback Function
openDropDown()
Defined by dijit/_HasDropDown

Opens the dropdown for this widget. To be called only when this.dropDown has been created and is ready to display (ie, it's data is loaded).

Returns:any | undefined

return value of dijit/popup.open()

postCreate()
Defined by dijit/_HasDropDown

set up nodes and connect our mouse and keyboard events

postMixInProperties()
reset()
toggleDropDown()
Defined by dijit/_HasDropDown

Callback when the user presses the down arrow button or presses the down arrow key to open/close the drop down. Toggle the drop-down widget; if it is up, close it, if not, open it

Events

_onBlur()
Defined by: dijit/_HasDropDown

Called magically when focus has shifted away from this widget and it's dropdown

_onDropDownClick(e)
Defined by: dijit/_HasDropDown
Parameter Type Description
e Event
_onDropDownMouseDown(e)
Defined by: dijit/_HasDropDown

Callback when the user mousedown/touchstart on the arrow icon.

Parameter Type Description
e Event
_onDropDownMouseUp(e)
Defined by: dijit/_HasDropDown

Callback on mouseup/touchend after mousedown/touchstart on the arrow icon. Note that this function is called regardless of what node the event occurred on (but only after a mousedown/touchstart on the arrow).

If the drop down is a simple menu and the cursor is over the menu, we execute it, otherwise, we focus our drop down widget. If the event is missing, then we are not a mouseup event.

This is useful for the common mouse movement pattern with native browser <select> nodes:

  1. mouse down on the select node (probably on the arrow)
  2. move mouse to a menu item while holding down the mouse button
  3. mouse up. this selects the menu item as though the user had clicked it.
Parameter Type Description
e Event
Optional
_onKey(e)
Defined by: dijit/_HasDropDown

Callback when the user presses a key while focused on the button node

Parameter Type Description
e Event
_onKeyUp()
Defined by: dijit/_HasDropDown
onSearch(results,query,options)

Callback when a search completes.

Parameter Type Description
results Object

An array of items from the originating _SearchMixin's store.

query Object

A copy of the originating _SearchMixin's query property.

options Object

The additional parameters sent to the originating _SearchMixin's store, including: start, count, queryOptions.

Error in the documentation? Can’t find what you are looking for? Let us know!