Problem summary: If you write SQL in the bound autosuggest function like this:

WHERE d_name LIKE '%#srch#%'

the coldfusion cfinput autosuggest function forces the result to START WITH the 
search term, where the SQL is looking for containment of the search string.  
So, for example, my query returns 10 matches, 6 start with the search term and 
4 contain the search term but not at the beginning.  The cfinput box only lists 
the 6 that start with the search term.  This is actually intended behavior by 
Coldfusion.

p658 of the cf8 developers guide reads:

"You do not have to limit the returned data to values that match the 
cfautosuggestvalue contents, because the client-side code displays only the 
values that match the user input."

Why force a filter on the results when we can do it ourselves?  Not good.

The problem is that is Coldfusion failed to think to pass a parameter to the 
YUI component AutoComplete.  It's defined in 
/CFIDE/scripts/ajax/yui/autocomplete/autocomplete-min.js.  

Search for this line: 
YAHOO.widget.DataSource.prototype.queryMatchContains=false;

Change the false to true.  

That fixes the problem.  

I'm not sure what other coldfusion functions use this component or what 
unexpected side effects this change will introduce. 

However, this change allows the autosuggest feature to to function as it 
should, where you have the control in your SQL of what results are displayed in 
the dropdown.  If you want the results to start with the search term, then 
search for 

WHERE d_name LIKE '#srch#%'

You could even return results totally unrelated to the searched term if you 
wanted to.

-Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303060
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to