Solved.
Issue with Child filtering vue 2.x
Hi there, I'm currently stuck with a computed vue filter and I cannot find the issue :(
Basically I have an data object filled with rows. Each row contains an title and multiple items. Each Item contains a booking_status from 1 to 4.
Now I have a filter where I can set an array with the values 1 to 4. When the filter array contains 1 and 2 I only want to see the items with the booking_status 1 or 2 in each row.
Vue deletes the items in data.rows if ids cannot be found in the filter. Why is the data.rows object being affected since I setup a computed rowsFiltered? Any idea?
Thanks for Help, Graveeel
computed: { rowsFiltered() { var rows = this.data.rows; var filter = this.filter;
// Title
if (this.filter.title != null) {
rows = this.data.rows.filter(function (row) {
if (row.title.indexOf(filter.title) > -1) {
return row;
}
});
}
// Booking Status
rows = rows.filter(function (row) {
row.items = row.items.filter(function (item) {
for (var i = 0; i < filter.booking_status.length; i++) {
if (item.booking_status_id == filter.booking_status[i]) {
return item;
}
}
});
return row;
});
return rows;
}
}
Please or to participate in this conversation.