dijit.form.FilteringSelect with substring search

核能气质少年 提交于 2019-12-04 17:58:07

问题


dijit.form.FilteringSelect is close to what I need. I've tried lots of ways to do what I want, but being a dijit beginner I never know if I'm even going in the right direction.

When I start typing in a FilteringSelect, I only see the options starting with what I typed. Like a query on value + "*"
What I need is to see any option that has what I type anywhere. Like a query on "*" + value + "*"

So if there is "Apple", "Banana" and "Orange", and I type "e", I should see "Apple" and "Orange". If possible, with the search string emphasized: "Apple", "Orange"

I think I need some clever data storage, but anywhere I go looks like a dead end. Am I missing something, or should I do this in a completely different way?


回答1:


You want to use the queryExpr attribute:

var f = new dijit.form.FilteringSelect({
 ...
 queryExpr: "*${0}*",
 ...
}, node);

Notice the * before and after the ${0}.




回答2:


Hey! You need to add queryExpr="${0}" to the filteringselect component.

By default, it's ${0}* , meaning it searches strings that start with what you typed.

As a hint for others, in JSP, I had to change the query expr. to queryExpr="\${0}" .




回答3:


In our project we solved this problem with a patch to dojo.data.util.filter overwriting patternToRegExp method.




回答4:


After a lot of time trying I could make it run, Mada tip was correct but miss the * before and after. The correct queryStr (in JSP) is '*\${0}*'




回答5:


Add backslash before $, { and } to resolve Uncaught error : dijit._WidgetsInTemplateMixin template 0 in html



来源:https://stackoverflow.com/questions/2094232/dijit-form-filteringselect-with-substring-search

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!