dijit/form/_SearchMixin (version 1.10)

Summary

A mixin that implements the base functionality to search a store based upon user-entered text such as with dijit/form/ComboBox or dijit/form/FilteringSelect

Usage

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

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

Property Summary

  • fetchPropertiesMixin to the store's fetch.
  • ignoreCaseSet true if the query should ignore case when matching possible items
  • listAlternate to specifying a store.
  • 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

  • onSearch(results,query,options) Callback when a search completes.

Properties

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} }
ignoreCase

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

list

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

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()
_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
_setListAttr(list)
Parameter Type Description
list undefined
_startSearch(text)

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

Parameter Type Description
text String
_startSearchFromInput()
postMixInProperties()

Events

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!