From 1f71cb5c5196c8a5e329048775d541e48245d6a1 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 4 Mar 2020 11:45:35 +0300 Subject: [PATCH] Add filterField and updated demos --- src/components/column/Column.d.ts | 1 + src/components/column/Column.vue | 4 + src/components/datatable/DataTable.vue | 2 +- src/components/utils/FilterUtils.js | 10 +- src/views/datatable/DataTableDemo.vue | 21 +-- src/views/datatable/DataTableDoc.vue | 186 ++++++++++++++++--------- 6 files changed, 139 insertions(+), 85 deletions(-) diff --git a/src/components/column/Column.d.ts b/src/components/column/Column.d.ts index 702ff610b..bdba862e0 100644 --- a/src/components/column/Column.d.ts +++ b/src/components/column/Column.d.ts @@ -4,6 +4,7 @@ export declare class Column extends Vue { columnKey?: any; field?: string; sortField?: string; + filterField?: string; sortable?: boolean; header?: any; footer?: any; diff --git a/src/components/column/Column.vue b/src/components/column/Column.vue index 10f048246..04b4b9077 100644 --- a/src/components/column/Column.vue +++ b/src/components/column/Column.vue @@ -14,6 +14,10 @@ export default { type: String, default: null }, + filterField: { + type: String, + default: null + }, sortable: { type: Boolean, default: false diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index 8b5e33e37..460409b13 100644 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -572,7 +572,7 @@ export default { for(let j = 0; j < this.columns.length; j++) { let col = this.columns[j]; - let columnField = col.field; + let columnField = col.filterField || col.field; //local if (Object.prototype.hasOwnProperty.call(this.filters, columnField)) { diff --git a/src/components/utils/FilterUtils.js b/src/components/utils/FilterUtils.js index 9df4cc2c4..eb7c2254a 100644 --- a/src/components/utils/FilterUtils.js +++ b/src/components/utils/FilterUtils.js @@ -87,7 +87,7 @@ export default class FilterUtils { } for (let i = 0; i < filter.length; i++) { - if (filter[i] === value || (value.getTime && filter[i].getTime && value.getTime() === filter[i].getTime())) { + if (ObjectUtils.equals(value, filter[i])) { return true; } } @@ -96,7 +96,7 @@ export default class FilterUtils { } static lt(value, filter) { - if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { + if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { return true; } @@ -111,7 +111,7 @@ export default class FilterUtils { } static lte(value, filter) { - if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { + if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { return true; } @@ -126,7 +126,7 @@ export default class FilterUtils { } static gt(value, filter) { - if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { + if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { return true; } @@ -141,7 +141,7 @@ export default class FilterUtils { } static gte(value, filter) { - if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { + if (filter === undefined || filter === null || (filter.trim && filter.trim().length === 0)) { return true; } diff --git a/src/views/datatable/DataTableDemo.vue b/src/views/datatable/DataTableDemo.vue index c0a99eb7e..385d7a37b 100644 --- a/src/views/datatable/DataTableDemo.vue +++ b/src/views/datatable/DataTableDemo.vue @@ -27,17 +27,17 @@ - + - +