I am working on this webpage where I want to display table rows based on the checkbox selection. I was able to generate working example using this question: Hide/show table rows based on checkbox
My problem is I am getting array as response instead of formatted rows. Not sure what am I missing here.
Please check the fiddle here: https://jsfiddle.net/4roe2kjq/1/
<html>
<style>
td {
border: thin solid black;
padding-right: 10px;
padding-bottom: 5px;
padding-left: 10px;
padding-top: 5px
}
</style>
<script src="/javascript/vue.js"></script>
<div id="app">
<div v-for="val in cbValues">
<label>
<input type='checkbox' :value='val' v-model="selectedType">
{{val}}
</label>
</div>
<table>
<template v-for="c in staff_member">
<tr v-if="isVisible(c)">
<td>{{c.courses}}</td>
</tr>
</template>
</table>
<script>
new Vue({
el: '#app',
data: {
selectedType: [],
staff_member:[{
description :'Non-lab Staff Member',
courses:[
{course :'first'},
{course :'second'}
]
}],
cbValues: [
'Non-lab Staff Member'
]
},
methods: {
isVisible(row) {
const matchedValue = this.cbValues.find(v => row.description.indexOf(v) >= 0);
if (!matchedValue) {
return true;
}
return this.selectedType.includes(matchedValue);
}
}
});
</script>
v-for?<head>and<body>v-for="c in staff_member<td v-for="({course}, key) in c.courses" :key="key">{{course}}</td>