2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<td :style="containerStyle" :class="containerClass">
|
2022-09-14 11:26:01 +00:00
|
|
|
<component v-if="column.children && column.children.footer" :is="column.children.footer" :column="column" />
|
|
|
|
{{ columnProp('footer') }}
|
2022-09-06 12:03:37 +00:00
|
|
|
</td>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-09-14 11:26:01 +00:00
|
|
|
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'FooterCell',
|
|
|
|
props: {
|
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
styleObject: {}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.columnProp('frozen')) {
|
|
|
|
this.updateStickyPosition();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
if (this.columnProp('frozen')) {
|
|
|
|
this.updateStickyPosition();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
columnProp(prop) {
|
|
|
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
|
|
|
},
|
|
|
|
updateStickyPosition() {
|
|
|
|
if (this.columnProp('frozen')) {
|
|
|
|
let align = this.columnProp('alignFrozen');
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
if (align === 'right') {
|
|
|
|
let right = 0;
|
|
|
|
let next = this.$el.nextElementSibling;
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
if (next) {
|
|
|
|
right = DomHandler.getOuterWidth(next) + parseFloat(next.style.right || 0);
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
this.styleObject.right = right + 'px';
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
let left = 0;
|
|
|
|
let prev = this.$el.previousElementSibling;
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
if (prev) {
|
|
|
|
left = DomHandler.getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
this.styleObject.left = left + 'px';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
containerClass() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return [
|
|
|
|
this.columnProp('footerClass'),
|
|
|
|
this.columnProp('class'),
|
|
|
|
{
|
|
|
|
'p-frozen-column': this.columnProp('frozen')
|
|
|
|
}
|
|
|
|
];
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
containerStyle() {
|
|
|
|
let bodyStyle = this.columnProp('footerStyle');
|
|
|
|
let columnStyle = this.columnProp('style');
|
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
return this.columnProp('frozen') ? [columnStyle, bodyStyle, this.styleObject] : [columnStyle, bodyStyle];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|