How can I access values of other columns with v-slot:cell?

Viewed 99

With a b-table, I am using a template for a column. In this example, I have the column id. Here, I can get the value of id for the current row by using data.value. But within this template I also need the value from another column for this row. How can I get that?

<template v-slot:cell(id)="data">
2 Answers

I think you have access to item in the props. So in your case should be data.item and from the item you can get the other value.

The slot-scope of table cells includes value and item. item being the data of the entire row.

<template v-slot:cell(id)="{ value, item }">
 {{ value }} <-- value of this row, i.e. item.id
 {{ item.anotherKey }} <-- value of another row
</template>
Related