-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(typeahead): support multiple search field values #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
multi select is planned feature |
@valorkin This doesn't feel like a concern of typeahead. Instead @Abrissirba you should write a service that does this. This is based on the asynchronous example in the documentation.
I use this technique searching for people when matching on first and last name. |
@critchie elegant solution! Thank you :) |
This is very much needed, I don't think the OP wants there to be multi select, just be able to filter the drop down list by more than one field in an array of objects. He or she can then select just one from that list. |
Once you have moved beyond the simple string/array of strings comparison the typeahead really can't make any assumptions about the filtering algorithm. To do what is being requested @valorkin and company would have to make assumptions about the filtering algorithm. The first assumption that comes to mind is what relational operator to use when determining a match. Is it "name AND country" or is it "name OR country"? Returning an Observable where you explicitly define the filtering is much cleaner IMO. |
Or allow predicates, or configurable pipes |
how is the progress on this? |
@sanyooh nearest 2 weeks I am focused on new datepicker (available from v1.9.0) |
Looking forward to this, it would be great to be able to do something like in uib-typeahead, ie: typeaheadOptionField(id+', '+title) |
I have a similar problem. I have an array of objects. I would like the typeahead to allow me to specify a field to use to match, and a field to use for display, and another field to use for the value.
Do you think that would be possible? |
I am getting ERROR TypeError: Cannot read property 'startsWith' of undefined. |
Search by multiple fields, Any updates on this implementation ? |
I'm with @jschank in that Typeahead should be more flexible in what is matched, displayed, and used for the selected value(s). |
Any updates on this? I'm not sure if I need to open a new issue, but I was wondering if TypeAheadOptionField supports multiple strings. I'd like to display a second property in my current dropdown on the Options field: The html for the dropdown:
and the way I'm binding to it from my TS component:
My school component also has a string address property that needs to also display in the search results. Not exactly sure how I'd do it. Also the documentation link provided above: https://valor-software.com/ng2-bootstrap/#/typeahead is broken can someone update the link? |
any updates on this? 💯 |
I solved it doing this
|
The solution for @awaheed1 is to use a templated list.
This allows you to display multiple options with your own make-up/lay-out. The problem I am facing thereafter is that the Now I understand I can map the two properties to a single string and have that be the search and selection criteria with the original object as a seperate property, but that doesn't seem to be an elegant solution? ngb-typeahead allows you to use a function as the displayed value, but that doesn't seem to work on ngx-typeahead? |
@critchie 's answer is still valid. The update link is below: |
An <input id="username" type="text" class="form-control"
[ngModel]="data"
[typeahead]="users" autocomplete="off"
[typeaheadOptionFieldFn]="optionFieldFn"
[typeaheadScrollable]="true"> optionFieldFn(match: TypeaheadMatch) {
const {item} = match;
return `${item.name}${item.surname}${item.id}`;
} |
|
I am trying to use typeahead in a scenario where we need to filter the search result based on multiple fields. Lets say we have an object like this
Then if I search on "Stock" I want the Stockholm object as result. If I search for "Swe" I want both Stockholm and Gothenburg. The matching function should therefore look for a match on both the name and country property.
The text was updated successfully, but these errors were encountered: