简体   繁体   English

Dojo FilteringSelect中的自动完成项列表

[英]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. 我有一个典型的FilteringSelect,当我键入它时可以使用,并且可以从框中检索值,这很好。 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'. 然后输入“ a”,我想要一个使我成为“ apple”和“ axe”的数组。

I'm assuming this will go somewhere in the onKeyPress: function , I'm just not familiar enough with the documentation. 我假设这将在onKeyPress:函数中的某个地方进行,我只是对该文档不够熟悉。 I've looked into dijit.byId('selectId') but from there I just don't know the API/documentation well enough 我已经研究过dijit.byId('selectId'),但是从那里我对API /文档的了解还不够

You should look at the API Documentation . 您应该查看API文档 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: 阅读时,您应该进入名为onSearch的事件,该事件返回3个参数:

  • the query 查询
  • the results 结果
  • some options 一些选择

So what you want is the onSearch event and read the results parameter. 因此,您需要的是onSearch事件并读取results参数。 I made a JSFiddle to show you an example. 我做了一个JSFiddle给您看一个例子。

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. 另一种可能的解决方案是直接查询商店,如果您不需要FilteringSelect ,但是只想根据查询获取商品列表,这将很有用。 You can also see how that works in my JSFiddle. 您也可以在我的JSFiddle中查看其工作方式。

EDIT: I Just noticed that you can't access the API documentation. 编辑:我只是注意到您无法访问API文档。 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. 然后,您真的应该尝试使用其他浏览器,因为API文档包含很多有趣的东西,并且通常是事件/方法和属性的参考。

I would have a look at the following properties from the Dojo API page: https://dojotoolkit.org/api/ (click on dijit/form/FilteringSelect) 我将在Dojo API页面上查看以下属性: https : //dojotoolkit.org/api/ (单击dijit / form / FilteringSelect)

query 询问

Defined by dijit/form/_SearchMixin 由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. ComboBox覆盖对searchAttr的所有引用,并将其设置为queryExpr,并替换用户的输入。

queryExpr queryExpr

Defined by dijit/form/_SearchMixin 由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. 更改此表达式将修改结果是否仅是完全匹配,“以...开头”匹配等。dojo.data查询表达式模式。 ${0} will be substituted for the user text. $ {0}将代替用户文本。 * is used for wildcards. *用于通配符。 ${0}* means "starts with", ${0} means "contains", ${0} means "is" $ {0} *表示“开始于”, $ {0}表示“包含”,$ {0}表示“是”

searchAttr searchAttr

Defined by dijit/form/_SearchMixin 由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. 例如(您还没有尝试过这样做,所以不确定它是否可以工作):*使用attr检索或设置dojo属性。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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