#6390 closed defect (fixed)
[patch] Can't search all in ComboBox / FilteringSelect
Reported by: | guest | Owned by: | haysmark |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Dijit - Form | Version: | 1.1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
ComboBox? (also FilteringSelect?) doesn't allow search all. Ticket #5281 requested a way of choosing whether to search from the start of the string, at the end, or both. The attribute queryExpr was added to facilitate this.
However, after the implementation, the ComboBox?'s fetch function http://trac.dojotoolkit.org/browser/dijit/trunk/form/ComboBox.js?rev=13252#L984 can only replace the first of the asterisks (when queryExpr = "*${0}*"), resulting in incorrect searches (though "begins with" or "ends with" should both have been fine).
The fetch function:
fetch: function(/* Object */ args){ // summary: // Given a query and set of defined options, such as a start and count of items to return, // this method executes the query and makes the results available as data items. // Refer to dojo.data.api.Read.fetch() more details. // // description: // Given a query like // // | { // | query: {name: "Cal*"}, // | start: 30, // | count: 20, // | ignoreCase: true, // | onComplete: function(/* item[] */ items, /* Object */ args){...} // | } // // will call `onComplete()` with the results of the query (and the argument to this method) // convert query to regex (ex: convert "first\last*" to /^first\\last.*$/i) and get matching vals var query = "^" + args.query.name .replace(/([\\\|\(\)\[\{\^\$\+\?\.\<\>])/g, "\\$1") .replace("*", ".*") + "$", matcher = new RegExp(query, args.queryOptions.ignoreCase ? "i" : ""), items = dojo.query("> option", this.root).filter(function(option){ return (option.innerText || option.textContent || '').match(matcher); } ); var start = args.start || 0, end = ("count" in args && args.count != Infinity) ? (start + args.count) : items.length ; args.onComplete(items.slice(start, end), args); return args; // Object // TODO: I don't need to return the length? },
I believe the fix would simply be to change line 1006 from:
.replace("*", ".*") + "$";
to:
.replace(/\*/g, ".*") + "$";
Attachments (1)
Change History (5)
comment:1 Changed 13 years ago by
Milestone: | → 1.2 |
---|---|
Owner: | set to haysmark |
Changed 13 years ago by
Attachment: | 6390.patch added |
---|
comment:2 Changed 13 years ago by
Status: | new → assigned |
---|---|
Summary: | Can't search all in ComboBox / FilteringSelect → [patch] Can't search all in ComboBox / FilteringSelect |
comment:3 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [14220]) Fixes #6390: Can't search all in ComboBox? / FilteringSelect? Patch from Mark Hays. !strict
comment:4 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
Fixes #6390. Expands filtering capabilities of _ComboBoxDataStore.