I have a table in vue template, The search is not working, Don't know what i missed.
<input type="text" class="dv-header-input" v-model="query.search_input"
@keyup.enter="fetchRecords()">
And the table :
<tr v-for="row in filteredRow">
<td v-for="(value, key) in row">{{value}}</td>
</tr>
And the JS :
export default {
props: [
'source',
'title',
],
data() {
return {
model: { data: [] },
columns: {},
query: {
search_input: ''
},
}
},
created() {
this.fetchRecords()
},
methods: {
fetchRecords() {
var vm = this
// Not original API,
axios.get(/get/Details)
.then(function(response) {
Vue.set(vm.$data, 'model', response.data.model)
Vue.set(vm.$data, 'columns', response.data.columns)
})
.catch(function(response) {
console.log(response)
})
}
},
computed: {
filteredRow: function(){
return this.model.data.filter((row) => {
for(var key in row){
return String(row[key]).indexOf(this.query.search_input);
}
});
}
}
}
In filteredRow, I console.log(String(row[key]).indexOf(this.query.search_input))' which gives me 30 times 0.
What am i missing and whats the best approach.
keyinrow