From 2889aeae5bfc3ed33a2d6e1e01be73dd14d88335 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Tue, 19 Nov 2019 10:51:23 +0300 Subject: [PATCH] Frozen Columns for DataTable --- src/components/column/Column.d.ts | 1 + src/components/column/Column.vue | 4 + src/components/datatable/DataTable.vue | 98 +++++++++++++++++++-- src/components/datatable/ScrollableView.vue | 26 +++++- src/views/datatable/DataTableScrollDemo.vue | 18 ++++ 5 files changed, 138 insertions(+), 9 deletions(-) diff --git a/src/components/column/Column.d.ts b/src/components/column/Column.d.ts index f6d377115..56428fd39 100644 --- a/src/components/column/Column.d.ts +++ b/src/components/column/Column.d.ts @@ -23,4 +23,5 @@ export declare class Column extends Vue { rowReorderIcon?: string; reorderableColumn?: boolean; rowEditor?: boolean; + frozen?: boolean; } \ No newline at end of file diff --git a/src/components/column/Column.vue b/src/components/column/Column.vue index 3e5f9f705..15f3458c8 100644 --- a/src/components/column/Column.vue +++ b/src/components/column/Column.vue @@ -89,6 +89,10 @@ export default { rowEditor: { type: Boolean, default: false + }, + frozen: { + type: Boolean, + default: false } }, render() { diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index c09322c38..7f5f49d06 100644 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -40,9 +40,9 @@
- + + + + + + +
@@ -294,6 +329,10 @@ export default { type: Array, default: null }, + frozenWidth: { + type: String, + default: null + } }, data() { return { @@ -1485,6 +1524,33 @@ export default { } return columns; }, + frozenColumns() { + let frozenColumns = []; + + for(let col of this.columns) { + if(col.frozen) { + frozenColumns = frozenColumns||[]; + frozenColumns.push(col); + } + } + + return frozenColumns; + }, + scrollableColumns() { + let scrollableColumns = []; + + for(let col of this.columns) { + if(!col.frozen) { + scrollableColumns = scrollableColumns||[]; + scrollableColumns.push(col); + } + } + + return scrollableColumns; + }, + hasFrozenColumns() { + return this.frozenColumns.length > 0; + }, headerColumnGroup() { if (this.allChildren) { for (let child of this.allChildren) { @@ -1496,6 +1562,17 @@ export default { return null; }, + frozenHeaderColumnGroup() { + if (this.allChildren) { + for (let child of this.allChildren) { + if (child.$vnode.tag.indexOf('columngroup') !== -1 && child.type === 'frozenheader') { + return child; + } + } + } + + return null; + }, footerColumnGroup() { if (this.allChildren) { for (let child of this.allChildren) { @@ -1507,6 +1584,17 @@ export default { return null; }, + frozenFooterColumnGroup() { + if (this.allChildren) { + for (let child of this.allChildren) { + if (child.$vnode.tag.indexOf('columngroup') !== -1 && child.type === 'frozenfooter') { + return child; + } + } + } + + return null; + }, processedData() { if (this.lazy) { return this.value; diff --git a/src/components/datatable/ScrollableView.vue b/src/components/datatable/ScrollableView.vue index 180ce433e..1063b896f 100644 --- a/src/components/datatable/ScrollableView.vue +++ b/src/components/datatable/ScrollableView.vue @@ -1,5 +1,5 @@