I managed to do the trick with Vue-Good-Table-Next - this is a Vue-Good-Table for Vue 3 (in Beta stage).
Ok, exactly we will not add any class to the row here, but the goal is to mark the selected rows visually in some way, right?
So, at the beginning, I was already using the custom table cell slot as described here.
Then I added this first span inside each table cell:
<template #table-row="tableRowProps">
<span class="selected-bg"
v-if="$refs['websitesTableInner'].selectedRows.find(row => row.id == tableRowProps.row.id)">
</span>
<span>
{{tableRowProps.formattedRow[tableRowProps.column.field]}}
</span>
</template>
Here my VueGoodTable has ref="websitesTableInner"
(in my custom table component it is an inner table).
And here the actual content goes into the 2nd span. The first span appears only if the row is selected.
Now it's some CSS time:
<style>
.selected-bg{
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
background: #daeada;
}
.selected-bg+span{
position: relative;
z-index: 2;
}
.vgt-table.bordered td, .vgt-table.bordered th{
position: relative;
z-index: 2;
}
</style>
So we overlay the .selected-bg span over each cell. I tried to make it over the table row (position:relative;
to the tr
tag, not td
), but then cells borders are not visible.
.selected-bg+span
is your cell content that should be over the overlay.
This is the result:
https://prnt.sc/ktqQZGrHvScq
Hope this will help somebody.