dijit/form/_AutoCompleterMixin (version 1.10)

dijit/form/_SearchMixin

Summary

A mixin that implements the base functionality for dijit/form/ComboBox/dijit/form/FilteringSelect

All widgets that mix in dijit/form/_AutoCompleterMixin must extend dijit/form/_FormValueWidget.

Usage

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

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

Property Summary

  • _stopClickEvents
  • 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
  • fetchPropertiesMixin to the store's fetch.
  • 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.
  • maxHeight
  • 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.

Method Summary

Event Summary

  • _onKey(evt) Handles keyboard events
  • onSearch(results,query,options) Callback when a search completes.

Properties

_stopClickEvents
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

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} }
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
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. The store must accept an object hash of properties for its query. See query and queryExpr for details.

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
_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
_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()

Display the drop down if not already displayed, or if it is displayed, then reposition it if necessary (reposition may be necessary if drop down's height changed).

_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()
closeDropDown()
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
isLoaded()
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

loadDropDown(callback)
Parameter Type Description
callback Function
postCreate()

Subclasses must call this method from their postCreate() methods

postMixInProperties()
reset()

Events

_onKey(evt)

Handles keyboard events

Parameter Type Description
evt Event
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!