Fixed #5006 - TableBody: Render "BodyRow" binding dataKey of props to key attribute

pull/4628/merge
mertsincan 2024-02-01 09:19:12 +00:00
parent fc1e3bdd47
commit 679977df48
1 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<template>
<tbody :ref="bodyRef" :class="cx('tbody')" role="rowgroup" :style="bodyStyle" v-bind="ptm('tbody', ptmTBodyOptions)">
<template v-if="!empty">
<template v-for="(rowData, rowIndex) of value" :key="rowIndex">
<template v-for="(rowData, rowIndex) of value" :key="getRowKey(rowData, rowIndex)">
<DTBodyRow
:rowData="rowData"
:index="rowIndex"
@ -71,7 +71,7 @@
<script>
import BaseComponent from 'primevue/basecomponent';
import { DomHandler, UniqueComponentId } from 'primevue/utils';
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
import BodyRow from './BodyRow.vue';
export default {
@ -248,6 +248,9 @@ export default {
}
},
methods: {
getRowKey(rowData, rowIndex) {
return this.dataKey ? ObjectUtils.resolveFieldData(rowData, this.dataKey) : rowIndex;
},
updateFrozenRowStickyPosition() {
this.$el.style.top = DomHandler.getOuterHeight(this.$el.previousElementSibling) + 'px';
},