Refactor #3924 - For ColumnGroup & Row

This commit is contained in:
Tuğçe Küçükoğlu 2023-05-10 14:39:25 +03:00
parent 05cb0588da
commit a52acf2a32
9 changed files with 159 additions and 6 deletions

View file

@ -1,12 +1,12 @@
<template>
<tfoot v-if="hasFooter" class="p-datatable-tfoot" role="rowgroup" v-bind="ptm('tfoot')">
<tfoot v-if="hasFooter" class="p-datatable-tfoot" role="rowgroup" v-bind="{ ...ptm('tfoot'), ...getColumnGroupPTOptions('root') }">
<tr v-if="!columnGroup" role="row" v-bind="ptm('footerRow')">
<template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i">
<DTFooterCell v-if="!columnProp(col, 'hidden')" :column="col" :pt="pt" />
</template>
</tr>
<template v-else>
<tr v-for="(row, i) of getFooterRows()" :key="i" role="row" v-bind="ptm('footerRow')">
<tr v-for="(row, i) of getFooterRows()" :key="i" role="row" v-bind="getRowPTOptions(row, 'root')">
<template v-for="(col, j) of getFooterColumns(row)" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || j">
<DTFooterCell v-if="!columnProp(col, 'hidden')" :column="col" :pt="pt" />
</template>
@ -37,6 +37,30 @@ export default {
columnProp(col, prop) {
return ObjectUtils.getVNodeProp(col, prop);
},
getColumnGroupPTOptions(key) {
return this.ptmo(this.getColumnGroupProps(), key, {
props: this.getColumnGroupProps(),
parent: {
props: this.$props,
state: this.$data
}
});
},
getColumnGroupProps() {
return this.columnGroup && this.columnGroup.props && this.columnGroup.props.pt ? this.columnGroup.props.pt : undefined; //@todo
},
getRowPTOptions(row, key) {
return this.ptmo(this.getRowProp(row), key, {
props: row.props,
parent: {
props: this.$props,
state: this.$data
}
});
},
getRowProp(row) {
return row.props && row.props.pt ? row.props.pt : undefined; //@todo
},
getFooterRows() {
let rows = [];