Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dijit.form.FilteringSelect with substring search

Tags:

dojo

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?

like image 903
myplacedk Avatar asked Jan 19 '10 14:01

myplacedk


2 Answers

You want to use the queryExpr attribute:

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

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

like image 148
waynebaylor Avatar answered Nov 10 '22 18:11

waynebaylor


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}" .

like image 4
Mada Avatar answered Nov 10 '22 18:11

Mada