I have a Vue app calculating a table with rowspans. The algorithm calculates the data ( and rowspans ) based on a configuration file so the application only renders the columns ( and the column order ) based on the calculated result.
Given the following sample ( Reproduction link )
<template>
<table>
<thead>
<th>City</th>
<th>Inhabitant</th>
<th>House</th>
<th>Room</th>
</thead>
<tbody>
<tr v-for="(row, rowIndex) in tableMatrix" :key="rowIndex">
<template v-for="(cell, columnIndex) in row" :key="columnIndex">
<td v-if="cell.isCoveredByPreviousCell" style="display: none" />
<td v-else :rowspan="cell.rowspan ?? 1">
<template v-if="cell.content">
{{ cell.content }}
</template>
</td>
</template>
</tr>
</tbody>
</table>
</template>
<script setup lang="ts">
import { ref, Ref } from 'vue';
interface Cell { isCoveredByPreviousCell: boolean; rowspan: number; content?: string; }
type TableMatrix = Cell[][];
const tableMatrix: Ref<TableMatrix> = ref([
[
{ isCoveredByPreviousCell: false, rowspan: 5, content: "City 1" },
{ isCoveredByPreviousCell: false, rowspan: 4, content: "Inhabitant 1" },
{ isCoveredByPreviousCell: false, rowspan: 3, content: "House 1" },
{ isCoveredByPreviousCell: false, content: "Room 1" },
],
[
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: false, content: "Room 2" },
],
[
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: false, content: "Room 3" },
],
[
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: false, content: "House 2" },
{ isCoveredByPreviousCell: false, content: "Room 1" },
],
[
{ isCoveredByPreviousCell: true },
{ isCoveredByPreviousCell: false, content: "Inhabitant 2" },
{ isCoveredByPreviousCell: false, content: "House 3" },
{ isCoveredByPreviousCell: false, content: "Room 1" },
]
])
</script>
<style>
table, th, td { border-collapse: collapse; border: 1px solid black; }
</style>
I get the following ( correct ) output
It's quite hard to identify a single "line", I'm looking for a way to make this more clear. A zebra striped table won't work for the table design. Maybe I need to add "dividing" rows with a fixed height and a different background color. Or increase the border bottom width of row cells.
I tried to add tr { border-bottom: 5px solid black; }
( reproduction link ) but then I get the following output
I also tried to add a dividing row ( reproduction link )
<tr>
<template v-for="(cell, columnIndex) in row" :key="columnIndex">
<td style="background: red">divider</td>
</template>
</tr>
but get this result
Do you have any ideas?