Basing on this How to render custom data in Bootstrap-Vue Table component? I created this code:
assignDocuments(id) {
const documents = this.$store.state.documentList.filter(e => e.user.idUser === id);
console.log(documents);
let i;
for(i=0; i < documents.length;i++) {
return documents[i] ? `${documents[i].filename}` : 'loading...';
}
}
but it doesn't work like I need... I need to display the names(filename) of all objects(in this case I have 2 objects in documents array) in array but now only name of first object is displayed in b-table.
EDIT:
B-table code:
<b-table ref="table" small striped hover :items="$store.state.userList" :fields="fields" head-variant="dark">
<template v-slot:cell(indexNumber)="row">
{{ row.item.indexNumber}}
</template>
<template v-slot:cell(name)="row">
{{ row.item.name}}
</template>
<template v-slot:cell(surname)="row">
{{ row.item.surname}}
</template>
<template v-slot:cell(specialization.specName)="row">
{{ row.item.specialization.specName}}
</template>
<template v-slot:cell(yearbook)="row">
{{ row.item.yearBook.startYear }}<b>/</b>{{ row.item.yearBook.endYear }}
</template>
<template v-slot:cell(details)="row">
<b-button size="sm" @click="row.toggleDetails" class="mr-2">
{{row.detailsShowing ? 'Ukryj' : 'Pokaż'}} Szczegóły
</b-button>
</template>
</b-table>
Fields:
fields:[
{
key: 'indexNumber',
label: 'Numer indeksu'
},
{
key: 'name',
label: 'Imię'
},
{
key: 'surname',
label: 'Nazwisko',
},
{
key: 'specialization.specName',
label: 'Kierunek',
},
{
key: 'yearBook',
label: 'Rocznik',
},
{
key: 'idUser',
label: 'Documents',
formatter: 'assignDocuments'
},
{
key: 'details',
label: 'Szczegóły',
},
],