To create a table, I want to use additional JSON - "tdTyp". Without data-table, I created a similar table using v-for and everything worked:
<td>{{ td.status }}</td>
<td>{{ $data.tdTyp[td.typ - 1].bezeichnung }}</td>
With the row "Typ":
<v-data-table
:headers="headers"
:items="tdData"
:search="search"
></v-data-table>
export default {
data () {
return {
tdData: resTdData,
tdTyp: resTdTyp
}
},
computed: {
headers () {
return [
{ text: 'Status', value: 'status' },
{ text: 'Typ', value: `${this.tdTyp['typ' - 1].bezeichnung}` }, // 'typ' is number. I need for example: { text: 'Typ', value: this.tdTyp[0].bezeichnung }
]}
}
}
resTdTyp JSON:
[{"bezeichnung": "Gesetz", "id": 1}, {"bezeichnung": "Verordnung", "id": 2}]
resTdData JSON:
[{"status": 1, "text": "text", "typ": 1}, {"status": 0, "text": "text", "typ": 4}]
Error:
Cannot read properties of undefined (reading 'bezeichnung')
It works fine:
{ text: 'Typ', value: 'typ' } // 1,2,3,4...
And also i want to add icons:
{ text: 'Status', value: '(status === 1) ? <img src="#" /> : ""' } //status - 0 or 1
I'm new in JS. Perhaps post-processing of this table is needed here or pre-processing array from JSON?