From 51206b79ed270d856fba96b2b2783be1ff50e92a Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Tue, 3 Mar 2020 12:25:27 +0300 Subject: [PATCH] Fixed #216 - sortfield is ignored --- src/components/datatable/TableHeader.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/datatable/TableHeader.vue b/src/components/datatable/TableHeader.vue index 7b18121a2..468959162 100644 --- a/src/components/datatable/TableHeader.vue +++ b/src/components/datatable/TableHeader.vue @@ -86,7 +86,7 @@ export default { }, methods: { getColumnHeaderClass(column) { - const sorted = this.sortMode === 'single' ? (this.sortField === column.field || this.sortField === column.sortField) : this.getMultiSortMetaIndex(column) > -1; + const sorted = this.sortMode === 'single' ? (this.sortField && (this.sortField === column.field || this.sortField === column.sortField)) : this.getMultiSortMetaIndex(column) > -1; return [column.headerClass, {'p-sortable-column': column.sortable}, @@ -99,7 +99,7 @@ export default { let sortOrder = null; if (this.sortMode === 'single') { - sorted = (this.sortField === column.field || this.sortField === column.sortField); + sorted = this.sortField && (this.sortField === column.field || this.sortField === column.sortField); sortOrder = sorted ? this.sortOrder: 0; } else if (this.sortMode === 'multiple') { @@ -123,7 +123,7 @@ export default { for (let i = 0; i < this.multiSortMeta.length; i++) { let meta = this.multiSortMeta[i]; - if (meta.field === (column.field || column.sortField)) { + if (meta.field === column.field || meta.field === column.sortField) { index = i; break; }