2π
I came up with this:
- Have the searchable prop in your items array:
items: [
// ...
{ name: "MEDIHEAL Beauty Mask", quantity: 483, price: 0, somePropThatsNotVisible: "String it could be found by" }
// ...
]
- Use a custom filter:
<v-data-table :headers="headers" :items="items" :search="search" :custom-filter="filter">
methods: {
filter (value, search, item) {
return Object.values(item).some(prop => {
return String(prop).includes(search)
})
}
},
Thatβs it! now all props are searchable but not shown if not included in the headers.
π€SneakyLenny
1π
You can override the filter property on the header definition for that column.
headers: [
{
text: "Product Name", value: "name", filter: product => {
// compare product.property against this.search and return true/false
}
},
// ... your other col definitions
]
π€Ohgodwhy
- [Vuejs]-How can I share a vue componenent state by sharing an url?
- [Vuejs]-How can I share a vue componenent state by sharing an url?
Source:stackexchange.com