Autocomplete editor doesn't work when specifying label/values and custom search function
See original GitHub issueIs your feature request related to a problem? Please describe. Autocomplete editor does not work when specifying display labels that are different than the value you want to store, i.e.
{title:"Name", field:"name", editor:"autocomplete", editorParams:{
values:{
"steve":"Steve Boberson",
"bob":"Bob Jimmerson",
"jim":"Jim Stevenson",
}
}}
and specifying a custom searchFunc:
searchFunc:function(term, values){ //search for exact matches
var matches = []
values.forEach(function(item){
if(item.value === term){
matches.push(item);
}
});
return matches;
},
Describe the solution you’d like When using both searchFunc and the object key/value pair for different label values, I would like to be able to return the same object key/value pair structure as specified in the values propery
Describe alternatives you’ve considered I have tried returning an object with matching key/value pairs from the searchFunc as initially sent to the values property, and returning just an array of the matching keys, neither works
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Issue with custom properties in jQuery UI Autocomplete
The issue is that there are no label and value properties specified, so by default autocomplete tries to search the text box value...
Read more >Populating autocomplete with Sources - Algolia
Autocomplete lets you fetch from different sources and display different types of results that serve different purposes.
Read more >_renderItem for jquery Autocomplete doesn´t work ...
Hello i would made an Autocomplete function for an intern order form. ... Autocomplete recognizes "label" as the key for the values you...
Read more >Building an accessible autocomplete control - Adam Silver
Unfortunately, native HTML form controls just aren't good enough for this type of interaction. And so we need to build a custom autocomplete...
Read more >Lightweight Autocomplete Controls with the HTML5 Datalist
Too many options in your HTML Select list? Try a Datalist! Learn how to work with this lightweight, accessible, cross-browser autocomplete ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey All,
So the issue relates specifically to when the searchFunc was being used, it wasn’t consistently handling the results from the different types of the values passed into the values property.
I have tweaked the way the function operates, regardless of the type of input the searchFunc function will be passed in an array of search item objects with the format:
The function must now return an array of these objects that match your search criteria, (these must be the same objects passed in to the function, you cannot rebuild them or it will break the references)
so an example search function that does a strict comparison would be:
I will include these changes in the 4.2.4 patch release later this weekend and update the documentation to match.
Cheers
Oli 😃
I have noticed a similar issue when trying to use custom searchFunc with autocomplete editor like this:
When running this I always get the following exception:
tabulator.min.js:7 Uncaught TypeError: Cannot create property ‘element’ on string ‘Accounts’ at tabulator.min.js:7 at Array.forEach (<anonymous>) at l (tabulator.min.js:7) at a (tabulator.min.js:7) at HTMLInputElement.<anonymous> (tabulator.min.js:7) at tabulator.min.js:7 at w.edit (tabulator.min.js:6) at HTMLDivElement.<anonymous> (tabulator.min.js:6)