I have a vuetify data-table I want to filter: https://codepen.io/rasenkantenstein/pen/MWYEvzK. I have filter containing a string, e.g. "Ice". Now I want to retrieve all records that contain an ingredient, which name contains ice.
[
{
name:
'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
ingredients:
[
{
ingName: 'Yogurt',
ingMeasure: 'gramm',
ingAmount: 100,
},
{
ingName: 'Ice',
ingMeasure: 'ml',
ingAmount: 50,
}
]
},
{
name:
'Vanilla Ice Cream',
calories: 100,
fat: 2.0,
carbs: 25,
protein: 2.0,
ingredients:
[
{
ingName: 'Milk',
ingMeasure: 'ml',
ingAmount: 100,
},
{
ingName: 'Vanilla Sugar',
ingMeasure: 'g',
ingAmount: 50,
},
{
ingName: 'Ice',
ingMeasure: 'g',
ingAmount: 50,
}
]
}
]
I have tried (very much like a rookie) to implement the filter on line 61.
filterIng (value) {
console.log(value)
if (!this.ingFilterValue) {
return true;
}
value.filter(x => {return x.ingName === this.ingFilterValue})
}
The function filterIng already iterates each record (as is evident in the console). The "value" contains an array of objects, among one is called ingName.
When filtering "Ice" (ingFilterValue = "Ice"), both records should return true. In case of ingFilterValue = "Yog" only record 1 should return true and record2 should return false.