Refactor #3924 - For TreeTable

pull/3847/head^2
Tuğçe Küçükoğlu 2023-05-11 11:11:49 +03:00
parent 6b9c617700
commit f541096d33
9 changed files with 284 additions and 38 deletions

View File

@ -221,6 +221,12 @@ const TreeTableProps = [
type: 'string', type: 'string',
default: 'null', default: 'null',
description: 'Defines the responsive mode, currently only option is scroll.' description: 'Defines the responsive mode, currently only option is scroll.'
},
{
name: 'pt',
type: 'any',
default: 'null',
description: 'Uses to pass attributes to DOM elements inside the component.'
} }
]; ];

View File

@ -78,6 +78,7 @@ import { ToastPassThroughOptions } from '../toast';
import { ToolbarPassThroughOptions } from '../toolbar'; import { ToolbarPassThroughOptions } from '../toolbar';
import { TreePassThroughOptions } from '../tree'; import { TreePassThroughOptions } from '../tree';
import { TreeSelectPassThroughOptions } from '../treeselect'; import { TreeSelectPassThroughOptions } from '../treeselect';
import { TreeTablePassThroughOptions } from '../treetable';
import { DefaultPTOptions } from '../ts-helpers'; import { DefaultPTOptions } from '../ts-helpers';
import { VirtualScrollerPassThroughOptions } from '../virtualscroller'; import { VirtualScrollerPassThroughOptions } from '../virtualscroller';
@ -179,6 +180,7 @@ interface PrimeVuePTOptions {
toolbar?: DefaultPTOptions<ToolbarPassThroughOptions>; toolbar?: DefaultPTOptions<ToolbarPassThroughOptions>;
tree?: DefaultPTOptions<TreePassThroughOptions>; tree?: DefaultPTOptions<TreePassThroughOptions>;
treeselect?: DefaultPTOptions<TreeSelectPassThroughOptions>; treeselect?: DefaultPTOptions<TreeSelectPassThroughOptions>;
treetable?: DefaultPTOptions<TreeTablePassThroughOptions>;
virtualscroller?: DefaultPTOptions<VirtualScrollerPassThroughOptions>; virtualscroller?: DefaultPTOptions<VirtualScrollerPassThroughOptions>;
} }

View File

@ -19,11 +19,11 @@
<span v-if="resizableColumns && !columnProp('frozen')" class="p-column-resizer" @mousedown="onResizeStart" v-bind="getColumnPTOptions('columnResizer')"></span> <span v-if="resizableColumns && !columnProp('frozen')" class="p-column-resizer" @mousedown="onResizeStart" v-bind="getColumnPTOptions('columnResizer')"></span>
<div class="p-column-header-content" v-bind="getColumnPTOptions('headerContent')"> <div class="p-column-header-content" v-bind="getColumnPTOptions('headerContent')">
<component v-if="column.children && column.children.header" :is="column.children.header" :column="column" /> <component v-if="column.children && column.children.header" :is="column.children.header" :column="column" />
<span v-if="columnProp('header')" class="p-column-title" v-bind="{ ...getColumnPTOptions('headerTitle') }">{{ columnProp('header') }}</span> <span v-if="columnProp('header')" class="p-column-title" v-bind="getColumnPTOptions('headerTitle')">{{ columnProp('header') }}</span>
<span v-if="columnProp('sortable')" v-bind="{ ...getColumnPTOptions('sort') }"> <span v-if="columnProp('sortable')" v-bind="getColumnPTOptions('sort')">
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" class="p-sortable-column-icon" /> <component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" class="p-sortable-column-icon" />
</span> </span>
<span v-if="isMultiSorted()" class="p-sortable-column-badge" v-bind="{ ...getColumnPTOptions('sortBadge') }">{{ getBadgeValue() }}</span> <span v-if="isMultiSorted()" class="p-sortable-column-badge" v-bind="getColumnPTOptions('sortBadge')">{{ getBadgeValue() }}</span>
<DTHeaderCheckbox <DTHeaderCheckbox
v-if="columnProp('selectionMode') === 'multiple' && filterDisplay !== 'row'" v-if="columnProp('selectionMode') === 'multiple' && filterDisplay !== 'row'"
:checked="allRowsSelected" :checked="allRowsSelected"

View File

@ -1,27 +1,28 @@
<template> <template>
<td :style="containerStyle" :class="containerClass" role="cell"> <td :style="containerStyle" :class="containerClass" role="cell" v-bind="{ ...getColumnPTOptions('root'), ...getColumnPTOptions('bodyCell') }">
<button v-if="columnProp('expander')" v-ripple type="button" class="p-treetable-toggler p-link" @click="toggle" :style="togglerStyle" tabindex="-1"> <button v-if="columnProp('expander')" v-ripple type="button" class="p-treetable-toggler p-link" @click="toggle" :style="togglerStyle" tabindex="-1" v-bind="getColumnPTOptions('rowToggler')">
<component v-if="templates['togglericon']" :is="templates['togglericon']" :node="node" :expanded="expanded" class="p-tree-toggler-icon" /> <component v-if="templates['togglericon']" :is="templates['togglericon']" :node="node" :expanded="expanded" class="p-tree-toggler-icon" />
<component v-else-if="expanded" :is="node.expandedIcon ? 'span' : 'ChevronDownIcon'" class="p-tree-toggler-icon" /> <component v-else-if="expanded" :is="node.expandedIcon ? 'span' : 'ChevronDownIcon'" class="p-tree-toggler-icon" v-bind="getColumnPTOptions('rowTogglerIcon')" />
<component v-else :is="node.collapsedIcon ? 'span' : 'ChevronRightIcon'" class="p-tree-toggler-icon" /> <component v-else :is="node.collapsedIcon ? 'span' : 'ChevronRightIcon'" class="p-tree-toggler-icon" v-bind="getColumnPTOptions('rowTogglerIcon')" />
</button> </button>
<div v-if="checkboxSelectionMode && columnProp('expander')" :class="['p-checkbox p-treetable-checkbox p-component', { 'p-checkbox-focused': checkboxFocused }]" @click="toggleCheckbox"> <div v-if="checkboxSelectionMode && columnProp('expander')" :class="['p-checkbox p-treetable-checkbox p-component', { 'p-checkbox-focused': checkboxFocused }]" @click="toggleCheckbox" v-bind="getColumnPTOptions('checkboxWrapper')">
<div class="p-hidden-accessible"> <div class="p-hidden-accessible" v-bind="getColumnPTOptions('hiddenInputWrapper')">
<input type="checkbox" @focus="onCheckboxFocus" @blur="onCheckboxBlur" tabindex="-1" /> <input type="checkbox" @focus="onCheckboxFocus" @blur="onCheckboxBlur" tabindex="-1" v-bind="getColumnPTOptions('hiddenInput')" />
</div> </div>
<div ref="checkboxEl" :class="checkboxClass"> <div ref="checkboxEl" :class="checkboxClass" v-bind="getColumnCheckboxPTOptions('checkbox')">
<component v-if="templates['checkboxicon']" :is="templates['checkboxicon']" :checked="checked" :partialChecked="partialChecked" class="p-checkbox-icon" /> <component v-if="templates['checkboxicon']" :is="templates['checkboxicon']" :checked="checked" :partialChecked="partialChecked" class="p-checkbox-icon" />
<component v-else :is="checked ? 'CheckIcon' : partialChecked ? 'MinusIcon' : null" class="p-checkbox-icon" /> <component v-else :is="checked ? 'CheckIcon' : partialChecked ? 'MinusIcon' : null" class="p-checkbox-icon" v-bind="getColumnCheckboxPTOptions('checkboxIcon')" />
</div> </div>
</div> </div>
<component v-if="column.children && column.children.body" :is="column.children.body" :node="node" :column="column" /> <component v-if="column.children && column.children.body" :is="column.children.body" :node="node" :column="column" />
<template v-else> <template v-else>
<span>{{ resolveFieldData(node.data, columnProp('field')) }}</span> <span v-bind="getColumnPTOptions('cellContent')">{{ resolveFieldData(node.data, columnProp('field')) }}</span>
</template> </template>
</td> </td>
</template> </template>
<script> <script>
import BaseComponent from 'primevue/basecomponent';
import CheckIcon from 'primevue/icons/check'; import CheckIcon from 'primevue/icons/check';
import ChevronDownIcon from 'primevue/icons/chevrondown'; import ChevronDownIcon from 'primevue/icons/chevrondown';
import ChevronRightIcon from 'primevue/icons/chevronright'; import ChevronRightIcon from 'primevue/icons/chevronright';
@ -31,6 +32,7 @@ import { DomHandler, ObjectUtils } from 'primevue/utils';
export default { export default {
name: 'BodyCell', name: 'BodyCell',
extends: BaseComponent,
emits: ['node-toggle', 'checkbox-toggle'], emits: ['node-toggle', 'checkbox-toggle'],
props: { props: {
node: { node: {
@ -97,6 +99,32 @@ export default {
columnProp(prop) { columnProp(prop) {
return ObjectUtils.getVNodeProp(this.column, prop); return ObjectUtils.getVNodeProp(this.column, prop);
}, },
getColumnPTOptions(key) {
return this.ptmo(this.getColumnProp(), key, {
props: this.column.props,
parent: {
props: this.$props,
state: this.$data
}
});
},
getColumnCheckboxPTOptions(key) {
return this.ptmo(this.getColumnProp(), key, {
props: this.column.props,
parent: {
props: this.$props,
state: this.$data
},
context: {
checked: this.checked,
focused: this.checkboxFocused,
partialChecked: this.partialChecked
}
});
},
getColumnProp() {
return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; //@todo
},
updateStickyPosition() { updateStickyPosition() {
if (this.columnProp('frozen')) { if (this.columnProp('frozen')) {
let align = this.columnProp('alignFrozen'); let align = this.columnProp('alignFrozen');

View File

@ -1,15 +1,17 @@
<template> <template>
<td :style="containerStyle" :class="containerClass"> <td :style="containerStyle" :class="containerClass" role="cell" v-bind="{ ...getColumnPTOptions('root'), ...getColumnPTOptions('footerCell') }">
<component v-if="column.children && column.children.footer" :is="column.children.footer" :column="column" /> <component v-if="column.children && column.children.footer" :is="column.children.footer" :column="column" />
{{ columnProp('footer') }} {{ columnProp('footer') }}
</td> </td>
</template> </template>
<script> <script>
import BaseComponent from 'primevue/basecomponent';
import { DomHandler, ObjectUtils } from 'primevue/utils'; import { DomHandler, ObjectUtils } from 'primevue/utils';
export default { export default {
name: 'FooterCell', name: 'FooterCell',
extends: BaseComponent,
props: { props: {
column: { column: {
type: Object, type: Object,
@ -35,6 +37,18 @@ export default {
columnProp(prop) { columnProp(prop) {
return ObjectUtils.getVNodeProp(this.column, prop); return ObjectUtils.getVNodeProp(this.column, prop);
}, },
getColumnPTOptions(key) {
return this.ptmo(this.getColumnProp(), key, {
props: this.column.props,
parent: {
props: this.$props,
state: this.$data
}
});
},
getColumnProp() {
return this.column.props && this.column.props.pt ? this.column.props.pt : undefined;
},
updateStickyPosition() { updateStickyPosition() {
if (this.columnProp('frozen')) { if (this.columnProp('frozen')) {
let align = this.columnProp('alignFrozen'); let align = this.columnProp('alignFrozen');

View File

@ -1,16 +1,26 @@
<template> <template>
<th :style="[containerStyle]" :class="containerClass" @click="onClick" @keydown="onKeyDown" :tabindex="columnProp('sortable') ? '0' : null" :aria-sort="ariaSort" role="columnheader"> <th
<span v-if="resizableColumns && !columnProp('frozen')" class="p-column-resizer" @mousedown="onResizeStart"></span> :style="[containerStyle]"
:class="containerClass"
@click="onClick"
@keydown="onKeyDown"
:tabindex="columnProp('sortable') ? '0' : null"
:aria-sort="ariaSort"
role="columnheader"
v-bind="{ ...getColumnPTOptions('root'), ...getColumnPTOptions('headerCell') }"
>
<span v-if="resizableColumns && !columnProp('frozen')" class="p-column-resizer" @mousedown="onResizeStart" v-bind="getColumnPTOptions('columnResizer')"></span>
<component v-if="column.children && column.children.header" :is="column.children.header" :column="column" /> <component v-if="column.children && column.children.header" :is="column.children.header" :column="column" />
<span v-if="columnProp('header')" class="p-column-title">{{ columnProp('header') }}</span> <span v-if="columnProp('header')" class="p-column-title" v-bind="getColumnPTOptions('headerTitle')">{{ columnProp('header') }}</span>
<span v-if="columnProp('sortable')"> <span v-if="columnProp('sortable')" v-bind="getColumnPTOptions('sort')">
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" class="p-sortable-column-icon" /> <component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" class="p-sortable-column-icon" />
</span> </span>
<span v-if="isMultiSorted()" class="p-sortable-column-badge">{{ getMultiSortMetaIndex() + 1 }}</span> <span v-if="isMultiSorted()" class="p-sortable-column-badge" v-bind="getColumnPTOptions('sortBadge')">{{ getMultiSortMetaIndex() + 1 }}</span>
</th> </th>
</template> </template>
<script> <script>
import BaseComponent from 'primevue/basecomponent';
import SortAltIcon from 'primevue/icons/sortalt'; import SortAltIcon from 'primevue/icons/sortalt';
import SortAmountDownIcon from 'primevue/icons/sortamountdown'; import SortAmountDownIcon from 'primevue/icons/sortamountdown';
import SortAmountUpAltIcon from 'primevue/icons/sortamountupalt'; import SortAmountUpAltIcon from 'primevue/icons/sortamountupalt';
@ -18,6 +28,7 @@ import { DomHandler, ObjectUtils } from 'primevue/utils';
export default { export default {
name: 'HeaderCell', name: 'HeaderCell',
extends: BaseComponent,
emits: ['column-click', 'column-resizestart'], emits: ['column-click', 'column-resizestart'],
props: { props: {
column: { column: {
@ -64,6 +75,18 @@ export default {
columnProp(prop) { columnProp(prop) {
return ObjectUtils.getVNodeProp(this.column, prop); return ObjectUtils.getVNodeProp(this.column, prop);
}, },
getColumnPTOptions(key) {
return this.ptmo(this.getColumnProp(), key, {
props: this.column.props,
parent: {
props: this.$props,
state: this.$data
}
});
},
getColumnProp() {
return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; //@todo:
},
updateStickyPosition() { updateStickyPosition() {
if (this.columnProp('frozen')) { if (this.columnProp('frozen')) {
let align = this.columnProp('alignFrozen'); let align = this.columnProp('alignFrozen');

View File

@ -8,9 +8,20 @@
* *
*/ */
import { VNode } from 'vue'; import { VNode } from 'vue';
import { PaginatorPassThroughOptionType } from '../paginator';
import { TreeNode } from '../tree'; import { TreeNode } from '../tree';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
export declare type TreeTablePassThroughOptionType = TreeTablePassThroughAttributes | ((options: TreeTablePassThroughMethodOptions) => TreeTablePassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface TreeTablePassThroughMethodOptions {
props: TreeTableProps;
state: TreeTableState;
}
/** /**
* Custom treetable filter metadata. * Custom treetable filter metadata.
*/ */
@ -153,6 +164,152 @@ export interface TreeTableSelectionKeys {
[key: string]: any; [key: string]: any;
} }
/**
* Custom passthrough(pt) options.
* @see {@link TreeTableProps.pt}
*/
export interface TreeTablePassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the loading wrapper's DOM element.
*/
loadingWrapper?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the loading overlay's DOM element.
*/
loadingOverlay?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the loading icon's DOM element.
*/
loadingIcon?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the header's DOM element.
*/
header?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the Paginator component.
* @see {@link PaginatorPassThroughOptionType}
*/
paginator?: PaginatorPassThroughOptionType;
/**
* Uses to pass attributes to the wrapper's DOM element.
*/
wrapper?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the table's DOM element.
*/
table?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the thead's DOM element.
*/
thead?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the header row's DOM element.
*/
headerRow?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the header cell's DOM element.
*/
headerCell?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the tbody's DOM element.
*/
tbody?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the empty message's DOM element.
*/
emptyMessage?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the body cell's DOM element.
*/
bodyCell?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the tfoot's DOM element.
*/
tfoot?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the footer row's DOM element.
*/
footerRow?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the footer's DOM element.
*/
footer?: TreeTablePassThroughOptionType;
/**
* Uses to pass attributes to the resize helper's DOM element.
*/
resizeHelper?: TreeTablePassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface TreeTablePassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in TreeTable component.
*/
export interface TreeTableState {
/**
* Current index of first record as a number.
*/
d_first: number;
/**
* Current number of rows to display in new page as a number.
*/
d_rows: number;
/**
* Current sort field.
*/
d_sortField: string | ((item: any) => string) | undefined;
/**
* Current order to sort the data by default.
*/
d_sortOrder: number;
/**
* Current sortmeta objects to sort the data.
*/
d_multiSortMeta: TreeTableSortMeta[];
/**
* Current group sortmeta objects to sort the data.
*/
d_groupRowsSortMeta: TreeTableSortMeta;
/**
* Current keys of selected rows.
*/
d_selectionKeys: any[];
/**
* Current keys of rows in expanded state.
*/
d_expandedRowKeys: any[];
/**
* Current order of the columns.
*/
d_columnOrder: string[];
/**
* Current keys of editing rows.
*/
d_editingRowKeys: any;
/**
* Current editing meta data.
*/
d_editingMeta: object;
/**
* Current filters object.
*/
d_filters: TreeTableFilterMeta;
/**
* Current editing as a boolean.
* @defaultValue false
*/
d_editing: boolean;
}
/** /**
* Defines valid properties in TreeTable component. * Defines valid properties in TreeTable component.
*/ */
@ -356,6 +513,11 @@ export interface TreeTableProps {
* Props to pass to the table element. * Props to pass to the table element.
*/ */
tableProps?: any | undefined; tableProps?: any | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {TreeTablePassThroughOptions}
*/
pt?: TreeTablePassThroughOptions;
} }
/** /**

View File

@ -1,13 +1,13 @@
<template> <template>
<div :class="containerClass" data-scrollselectors=".p-treetable-scrollable-body" role="table"> <div :class="containerClass" data-scrollselectors=".p-treetable-scrollable-body" role="table" v-bind="ptm('root')">
<div v-if="loading" class="p-treetable-loading"> <div v-if="loading" class="p-treetable-loading" v-bind="ptm('loadingWrapper')">
<div class="p-treetable-loading-overlay p-component-overlay"> <div class="p-treetable-loading-overlay p-component-overlay" v-bind="ptm('loadingOverlay')">
<slot name="loadingicon"> <slot name="loadingicon">
<component :is="loadingIcon ? 'span' : 'SpinnerIcon'" spin :class="['p-treetable-loading-icon', loadingIcon]" /> <component :is="loadingIcon ? 'span' : 'SpinnerIcon'" spin :class="['p-treetable-loading-icon', loadingIcon]" v-bind="ptm('loadingIcon')" />
</slot> </slot>
</div> </div>
</div> </div>
<div v-if="$slots.header" class="p-treetable-header"> <div v-if="$slots.header" class="p-treetable-header" v-bind="ptm('header')">
<slot name="header"></slot> <slot name="header"></slot>
</div> </div>
<TTPaginator <TTPaginator
@ -22,6 +22,7 @@
class="p-paginator-top" class="p-paginator-top"
@page="onPage($event)" @page="onPage($event)"
:alwaysShow="alwaysShowPaginator" :alwaysShow="alwaysShowPaginator"
:pt="ptm('paginator')"
> >
<template v-if="$slots.paginatorstart" #start> <template v-if="$slots.paginatorstart" #start>
<slot name="paginatorstart"></slot> <slot name="paginatorstart"></slot>
@ -42,10 +43,10 @@
<slot name="paginatorlastpagelinkicon"></slot> <slot name="paginatorlastpagelinkicon"></slot>
</template> </template>
</TTPaginator> </TTPaginator>
<div class="p-treetable-wrapper" :style="{ maxHeight: scrollHeight }"> <div class="p-treetable-wrapper" :style="{ maxHeight: scrollHeight }" v-bind="ptm('wrapper')">
<table ref="table" role="table" v-bind="tableProps"> <table ref="table" role="table" v-bind="{ ...tableProps, ...ptm('table') }">
<thead class="p-treetable-thead" role="rowgroup"> <thead class="p-treetable-thead" role="rowgroup" v-bind="ptm('thead')">
<tr role="row"> <tr role="row" v-bind="ptm('headerRow')">
<template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i"> <template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i">
<TTHeaderCell <TTHeaderCell
v-if="!columnProp(col, 'hidden')" v-if="!columnProp(col, 'hidden')"
@ -57,18 +58,19 @@
:sortMode="sortMode" :sortMode="sortMode"
@column-click="onColumnHeaderClick" @column-click="onColumnHeaderClick"
@column-resizestart="onColumnResizeStart" @column-resizestart="onColumnResizeStart"
:pt="pt"
></TTHeaderCell> ></TTHeaderCell>
</template> </template>
</tr> </tr>
<tr v-if="hasColumnFilter()"> <tr v-if="hasColumnFilter()" v-bind="ptm('headerRow')">
<template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i"> <template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i">
<th v-if="!columnProp(col, 'hidden')" :class="getFilterColumnHeaderClass(col)" :style="[columnProp(col, 'style'), columnProp(col, 'filterHeaderStyle')]"> <th v-if="!columnProp(col, 'hidden')" :class="getFilterColumnHeaderClass(col)" :style="[columnProp(col, 'style'), columnProp(col, 'filterHeaderStyle')]" v-bind="ptm('headerCell')">
<component v-if="col.children && col.children.filter" :is="col.children.filter" :column="col" /> <component v-if="col.children && col.children.filter" :is="col.children.filter" :column="col" />
</th> </th>
</template> </template>
</tr> </tr>
</thead> </thead>
<tbody class="p-treetable-tbody" role="rowgroup"> <tbody class="p-treetable-tbody" role="rowgroup" v-bind="ptm('tbody')">
<template v-if="!empty"> <template v-if="!empty">
<TTRow <TTRow
v-for="(node, index) of dataToRender" v-for="(node, index) of dataToRender"
@ -87,18 +89,19 @@
@node-toggle="onNodeToggle" @node-toggle="onNodeToggle"
@node-click="onNodeClick" @node-click="onNodeClick"
@checkbox-change="onCheckboxChange" @checkbox-change="onCheckboxChange"
:pt="pt"
></TTRow> ></TTRow>
</template> </template>
<tr v-else class="p-treetable-emptymessage"> <tr v-else class="p-treetable-emptymessage" v-bind="ptm('emptyMessage')">
<td :colspan="columns.length"> <td :colspan="columns.length" v-bind="ptm('bodyCell')">
<slot name="empty"></slot> <slot name="empty"></slot>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tfoot v-if="hasFooter" class="p-treetable-tfoot" role="rowgroup"> <tfoot v-if="hasFooter" class="p-treetable-tfoot" role="rowgroup" v-bind="ptm('tfoot')">
<tr role="row"> <tr role="row" v-bind="ptm('footerRow')">
<template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i"> <template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i">
<TTFooterCell v-if="!columnProp(col, 'hidden')" :column="col"></TTFooterCell> <TTFooterCell v-if="!columnProp(col, 'hidden')" :column="col" :pt="pt"></TTFooterCell>
</template> </template>
</tr> </tr>
</tfoot> </tfoot>
@ -116,6 +119,7 @@
class="p-paginator-bottom" class="p-paginator-bottom"
@page="onPage($event)" @page="onPage($event)"
:alwaysShow="alwaysShowPaginator" :alwaysShow="alwaysShowPaginator"
:pt="pt"
> >
<template v-if="$slots.paginatorstart" #start> <template v-if="$slots.paginatorstart" #start>
<slot name="paginatorstart"></slot> <slot name="paginatorstart"></slot>
@ -136,15 +140,16 @@
<slot name="paginatorlastpagelinkicon"></slot> <slot name="paginatorlastpagelinkicon"></slot>
</template> </template>
</TTPaginator> </TTPaginator>
<div v-if="$slots.footer" class="p-treetable-footer"> <div v-if="$slots.footer" class="p-treetable-footer" v-bind="ptm('footer')">
<slot name="footer"></slot> <slot name="footer"></slot>
</div> </div>
<div ref="resizeHelper" class="p-column-resizer-helper p-highlight" style="display: none"></div> <div ref="resizeHelper" class="p-column-resizer-helper p-highlight" style="display: none" v-bind="ptm('resizeHelper')"></div>
</div> </div>
</template> </template>
<script> <script>
import { FilterService } from 'primevue/api'; import { FilterService } from 'primevue/api';
import BaseComponent from 'primevue/basecomponent';
import SpinnerIcon from 'primevue/icons/spinner'; import SpinnerIcon from 'primevue/icons/spinner';
import Paginator from 'primevue/paginator'; import Paginator from 'primevue/paginator';
import { DomHandler, ObjectUtils } from 'primevue/utils'; import { DomHandler, ObjectUtils } from 'primevue/utils';
@ -154,6 +159,7 @@ import TreeTableRow from './TreeTableRow.vue';
export default { export default {
name: 'TreeTable', name: 'TreeTable',
extends: BaseComponent,
emits: [ emits: [
'node-expand', 'node-expand',
'node-collapse', 'node-collapse',

View File

@ -14,6 +14,7 @@
@click="onClick" @click="onClick"
@keydown="onKeyDown" @keydown="onKeyDown"
@touchend="onTouchEnd" @touchend="onTouchEnd"
v-bind="ptm('row')"
> >
<template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i"> <template v-for="(col, i) of columns" :key="columnProp(col, 'columnKey') || columnProp(col, 'field') || i">
<TTBodyCell <TTBodyCell
@ -30,6 +31,7 @@
:templates="templates" :templates="templates"
@node-toggle="$emit('node-toggle', $event)" @node-toggle="$emit('node-toggle', $event)"
@checkbox-toggle="toggleCheckbox" @checkbox-toggle="toggleCheckbox"
:pt="pt"
></TTBodyCell> ></TTBodyCell>
</template> </template>
</tr> </tr>
@ -51,16 +53,19 @@
@node-toggle="$emit('node-toggle', $event)" @node-toggle="$emit('node-toggle', $event)"
@node-click="$emit('node-click', $event)" @node-click="$emit('node-click', $event)"
@checkbox-change="onCheckboxChange" @checkbox-change="onCheckboxChange"
:pt="pt"
/> />
</template> </template>
</template> </template>
<script> <script>
import BaseComponent from 'primevue/basecomponent';
import { DomHandler, ObjectUtils } from 'primevue/utils'; import { DomHandler, ObjectUtils } from 'primevue/utils';
import BodyCell from './BodyCell.vue'; import BodyCell from './BodyCell.vue';
export default { export default {
name: 'TreeTableRow', name: 'TreeTableRow',
extends: BaseComponent,
emits: ['node-click', 'node-toggle', 'checkbox-change', 'nodeClick', 'nodeToggle', 'checkboxChange'], emits: ['node-click', 'node-toggle', 'checkbox-change', 'nodeClick', 'nodeToggle', 'checkboxChange'],
props: { props: {
node: { node: {