简体   繁体   中英

List of autocomplete items in Dojo FilteringSelect

I have a typical FilteringSelect that works when I type in it and I can retrieve the value from the box, which is good. However, I'm trying to determine if I can access to that list of items that it returns.

For instance, if I have the following items in my store:

apple
axe
bananna

And I type in 'a' I want to get the an array that gets me 'apple' and 'axe'.

I'm assuming this will go somewhere in the onKeyPress: function , I'm just not familiar enough with the documentation. I've looked into dijit.byId('selectId') but from there I just don't know the API/documentation well enough

You should look at the API Documentation . There you can see a summary of all events possible. When you read it, you should come to the event called onSearch which returns 3 parameters:

  • the query
  • the results
  • some options

So what you want is the onSearch event and read the results parameter. I made a JSFiddle to show you an example.

Another possible solution is to query the store directly, which can be useful if you don't need the FilteringSelect , but if you just want to get a list of items based on a query. You can also see how that works in my JSFiddle.

EDIT: I Just noticed that you can't access the API documentation. You should really try another browser then, since the API documentation contains a lot of interesting things and is usually the reference for events/methods and properties.

I would have a look at the following properties from the Dojo API page: https://dojotoolkit.org/api/ (click on dijit/form/FilteringSelect)

query

Defined by dijit/form/_SearchMixin

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

Defined by dijit/form/_SearchMixin

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. dojo.data query expression pattern. ${0} will be substituted for the user text. * is used for wildcards. ${0}* means "starts with", ${0} means "contains", ${0} means "is"

searchAttr

Defined by dijit/form/_SearchMixin

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

For example (Haven't tried this so not sure if it will work or not): * Use attr to retrieve or set dojo properties.

var srchItems = dijit.byId('resistForm').attr("searchAttr","a");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM