Skip to content

Commit c5d8563

Browse files
committed
Added useAttrs for table
1 parent aa7fa04 commit c5d8563

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

dev/TableShow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<input id="checkbox" :checked="row.item._showDetails" type="checkbox" @click.stop="row.toggleDetails(row.item)" />
5151
</template>
5252
</TVTable>
53-
53+
5454
<div class="text-left mt-2">
5555
Selected: {{ selectRow }}
5656
</div>

src/components/TVTable.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<span>Displaying {{ fromRow + 1 }} to {{ toRow }} of {{ totalRows }} items</span>
44
</div>
55

6-
<table class="min-w-full">
6+
<table ref="TVTABLE" class="min-w-full" v-bind="attrs">
77
<thead class="bg-gray-300 border divide-x divide-y">
88
<slot v-if="slots['header-row']" name="header-row" />
99
<tr class="divide-x divide-y">
@@ -65,9 +65,9 @@
6565
</div>
6666
</td>
6767
</tr>
68-
<template v-for="(item, index) in items" v-else :key="item.label">
68+
<template v-for="(item, index) in items" v-else :key="item.id">
6969
<tr
70-
:id="`TV_TABLE_row_${item.label}`"
70+
:id="`TVTABLE_row_${index}_${item.id}`"
7171
class="divide-x divide-y last:border-b-0 px-2 py-1.5 text-left text-xs font-medium border hover:bg-gray-400/50"
7272
:class="index % 2 ? 'bg-gray-300/50' : 'bg-gray-100/50'"
7373
@click="rowClicked(item)"
@@ -118,14 +118,15 @@
118118
</template>
119119

120120
<script setup>
121-
import {computed, defineComponent, ref, useSlots, watch} from 'vue';
121+
import {computed, defineComponent, ref, useAttrs, useSlots, watch} from 'vue';
122122
import TVPagination from './TVPagination.vue';
123123
124124
defineComponent({
125125
name: 'TVTable'
126126
})
127127
128128
const slots = useSlots();
129+
const attrs = useAttrs();
129130
130131
const props = defineProps({
131132
items: {

0 commit comments

Comments
 (0)