Using vuetify v-autocomplete with an object, the object is a Key and Value. When the user search, the search is based on the item-text. As you can see in my example I display the object Key and Value Example {1200-Chloride Systems}. So is it possible that when the user type the search is based on both the Key and Value of the object and not just the item-text?
<v-autocomplete
label="Trading Partner"
v-model="tradingPartner"
:items="tradingpartners"
item-value="Key"
item-text="Value"
return-object
>
<template slot="selection" slot-scope="{ item }">
{{ item.Key }} - {{ item.Value }}
</template>
<template slot="item" slot-scope="{ item }">
{{ item.Key }} - {{ item.Value }}
</template>
</v-autocomplete>
in the example below, you can see that 1200 is the key and Chloride Systems is the value. The display is concatenating Key - Value. If I clear the text and start typing I can search for the Name (Value), but if I type as example 1200 it finds nothing because the search is not on Key.

You could use custom filter prop which takes a function as value :
<v-autocomplete :filter="onFilter" ...
in methods:
methods:{
onFilter(item, queryText, itemText){
return item.Key.toLocaleLowerCase().includes(queryText.toLocaleLowerCase())
|| item.Value.toLocaleLowerCase().includes(queryText.toLocaleLowerCase())
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With