diff --git a/api-generator/components/treetable.js b/api-generator/components/treetable.js index 3c40403cf..337f37964 100644 --- a/api-generator/components/treetable.js +++ b/api-generator/components/treetable.js @@ -196,6 +196,24 @@ const TreeTableProps = [ type: "boolean", default: "false", description: "Whether to show grid lines between cells." + }, + { + name: "scrollable", + type: "boolean", + default: "false", + description: "When specified, enables horizontal and/or vertical scrolling." + }, + { + name: "scrollDirection", + type: "string", + default: "vertical", + description: 'Orientation of the scrolling, options are "vertical", "horizontal" and "both".' + }, + { + name: "scrollHeight", + type: "string", + default: "null", + description: 'Height of the scroll viewport in fixed units or the "flex" keyword for a dynamic size.' } ]; diff --git a/src/components/datatable/DataTable.d.ts b/src/components/datatable/DataTable.d.ts index 3c7fd2e66..dd9a7bb84 100755 --- a/src/components/datatable/DataTable.d.ts +++ b/src/components/datatable/DataTable.d.ts @@ -53,6 +53,7 @@ interface DataTableProps { rowClass?: any; scrollable?: boolean; scrollHeight?: string; + scrollDirection?: string; frozenValue?: any[]; responsiveLayout?: string; breakpoing?: string; diff --git a/src/components/treetable/BodyCell.vue b/src/components/treetable/BodyCell.vue new file mode 100644 index 000000000..ad276c6e0 --- /dev/null +++ b/src/components/treetable/BodyCell.vue @@ -0,0 +1,157 @@ + + + diff --git a/src/components/treetable/FooterCell.vue b/src/components/treetable/FooterCell.vue new file mode 100644 index 000000000..e9477aa6e --- /dev/null +++ b/src/components/treetable/FooterCell.vue @@ -0,0 +1,74 @@ + + + diff --git a/src/components/treetable/HeaderCell.vue b/src/components/treetable/HeaderCell.vue new file mode 100644 index 000000000..b2a850f8a --- /dev/null +++ b/src/components/treetable/HeaderCell.vue @@ -0,0 +1,170 @@ + + + diff --git a/src/components/treetable/TreeTable.d.ts b/src/components/treetable/TreeTable.d.ts index f7261a457..595d72a56 100755 --- a/src/components/treetable/TreeTable.d.ts +++ b/src/components/treetable/TreeTable.d.ts @@ -36,6 +36,9 @@ interface TreeTableProps { columnResizeMode?: string; indentation?: number; showGridlines?: boolean; + scrollable?: boolean; + scrollHeight?: string; + scrollDirection?: string; } declare class TreeTable { diff --git a/src/components/treetable/TreeTable.vue b/src/components/treetable/TreeTable.vue index 3167efa1b..80be66ee4 100755 --- a/src/components/treetable/TreeTable.vue +++ b/src/components/treetable/TreeTable.vue @@ -22,14 +22,9 @@ @@ -55,10 +50,7 @@ @@ -84,6 +76,8 @@ import {ObjectUtils,DomHandler} from 'primevue/utils'; import {FilterService} from 'primevue/api'; import TreeTableRow from './TreeTableRow.vue'; +import HeaderCell from './HeaderCell.vue'; +import FooterCell from './FooterCell.vue'; import Paginator from 'primevue/paginator'; export default { @@ -392,72 +386,15 @@ export default { this.d_first = 0; this.$emit('update:first', this.d_first); }, - isMultiSorted(column) { - return this.columnProp(column, 'sortable') && this.getMultiSortMetaIndex(column) > -1 - }, - isColumnSorted(column) { - if (this.columnProp(column, 'sortable')) { - return this.sortMode === 'single' ? (this.d_sortField === (this.columnProp(column, 'field') || this.columnProp(column, 'sortField'))) : this.getMultiSortMetaIndex(column) > -1; - } - - return false; - }, - getColumnHeaderClass(column) { - return [this.columnProp(column, 'headerClass'), { - 'p-sortable-column': this.columnProp(column, 'sortable'), - 'p-resizable-column': this.resizableColumns, - 'p-highlight': this.isColumnSorted(column), - 'p-frozen-column': this.columnProp(column, 'frozen') - }]; - }, getFilterColumnHeaderClass(column) { return ['p-filter-column', this.columnProp(column, 'filterHeaderClass'), { 'p-frozen-column': this.columnProp(column, 'frozen') }]; }, - getColumnFooterClass(column) { - return [this.columnProp(column, 'footerClass'), { - 'p-frozen-column': this.columnProp(column, 'frozen') - }]; - }, - getSortableColumnIcon(column) { - let sorted = false; - let sortOrder = null; + onColumnHeaderClick(e) { + let event = e.originalEvent; + let column = e.column; - if (this.sortMode === 'single') { - sorted = this.d_sortField === (this.columnProp(column, 'field')|| this.columnProp(column, 'sortField')); - sortOrder = sorted ? this.d_sortOrder: 0; - } - else if (this.sortMode === 'multiple') { - let metaIndex = this.getMultiSortMetaIndex(column); - if (metaIndex > -1) { - sorted = true; - sortOrder = this.d_multiSortMeta[metaIndex].order; - } - } - - return [ - 'p-sortable-column-icon pi pi-fw', { - 'pi-sort-alt': !sorted, - 'pi-sort-amount-up-alt': sorted && sortOrder > 0, - 'pi-sort-amount-down': sorted && sortOrder < 0 - } - ]; - }, - getMultiSortMetaIndex(column) { - let index = -1; - - for (let i = 0; i < this.d_multiSortMeta.length; i++) { - let meta = this.d_multiSortMeta[i]; - if (meta.field === (this.columnProp(column, 'field')|| this.columnProp(column, 'sortField'))) { - index = i; - break; - } - } - - return index; - }, - onColumnHeaderClick(event, column) { if (this.columnProp(column, 'sortable')) { const targetNode = event.target; const columnField = this.columnProp(column, 'sortField') || this.columnProp(column, 'field'); @@ -786,20 +723,6 @@ export default { this.onColumnHeaderClick(event, col); } }, - getAriaSort(column) { - if (this.columnProp(column, 'sortable')) { - const sortIcon = this.getSortableColumnIcon(column); - if (sortIcon[1]['pi-sort-amount-down']) - return 'descending'; - else if (sortIcon[1]['pi-sort-amount-up-alt']) - return 'ascending'; - else - return 'none'; - } - else { - return null; - } - }, hasColumnFilter() { if (this.columns) { for (let col of this.columns) { @@ -933,6 +856,8 @@ export default { components: { 'TTRow': TreeTableRow, 'TTPaginator': Paginator, + 'TTHeaderCell': HeaderCell, + 'TTFooterCell': FooterCell } } diff --git a/src/components/treetable/TreeTableRow.vue b/src/components/treetable/TreeTableRow.vue index 281fbf348..6a5c93f07 100755 --- a/src/components/treetable/TreeTableRow.vue +++ b/src/components/treetable/TreeTableRow.vue @@ -1,21 +1,10 @@ - + @@ -109,35 +109,81 @@ export default {