From 68a8af7cb8d1787a5285a87cb77064b3502ca15e Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Fri, 7 Feb 2020 10:23:19 +0300 Subject: [PATCH] Fixed #181 - DataTable "$event" argument on page/sort events does not contains filterSearchMode. --- src/components/datatable/DataTable.vue | 16 +++++++++++++--- src/views/datatable/DataTableDoc.vue | 20 ++++++++++---------- src/views/datatable/DataTableFilterDemo.vue | 4 ++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index f3fcac5d0c..9f7f5b8df5 100644 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -608,7 +608,7 @@ export default { } let filterEvent = this.createLazyLoadEvent(event); - filterEvent.filterValue = filteredValue; + filterEvent.filteredValue = filteredValue; this.$emit('filter', filterEvent); return filteredValue; @@ -1598,15 +1598,25 @@ export default { }, this.virtualScrollDelay); }, createLazyLoadEvent(event) { + let filterMatchModes; + if (this.hasFilters) { + filterMatchModes = {}; + this.columns.forEach(col => { + if (col.field) { + filterMatchModes[col.field] = col.filterMatchMode; + } + }); + } + return { originalEvent: event, first: this.d_first, rows: this.d_rows, sortField: this.d_sortField, sortOrder: this.d_sortOrder, + multiSortMeta: this.d_multiSortMeta, filters: this.filters, - globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null, - multiSortMeta: this.d_multiSortMeta + filterMatchModes: filterMatchModes }; } }, diff --git a/src/views/datatable/DataTableDoc.vue b/src/views/datatable/DataTableDoc.vue index a5c6585139..e0e8cd66d8 100644 --- a/src/views/datatable/DataTableDoc.vue +++ b/src/views/datatable/DataTableDoc.vue @@ -1970,45 +1970,45 @@ export default { page - event.page: New page number
+ event.originalEvent: Browser event
+ event.page: New page number
+ event.pageCount: Total page count
event.first: Index of first record
event.rows: Number of rows to display in new page
- event.pageCount: Total number of pages
event.sortField: Field to sort against
event.sortOrder: Sort order as integer
event.multiSortMeta: MultiSort metadata
event.filters: Collection of active filters
- event.filteredValue: Filtered collection + event.filterMatchModes: Match modes per field Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation. sort - event.page: New page number
+ event.originalEvent: Browser event
event.first: Index of first record
event.rows: Number of rows to display in new page
- event.pageCount: Total number of pages
event.sortField: Field to sort against
event.sortOrder: Sort order as integer
event.multiSortMeta: MultiSort metadata
event.filters: Collection of active filters
- event.filteredValue: Filtered collection + event.filterMatchModes: Match modes per field Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation. filter - event.page: New page number
+ event.originalEvent: Browser event
event.first: Index of first record
event.rows: Number of rows to display in new page
- event.pageCount: Total number of pages
event.sortField: Field to sort against
event.sortOrder: Sort order as integer
event.multiSortMeta: MultiSort metadata
event.filters: Collection of active filters
- event.filteredValue: Filtered collection + event.filteredValue: Filtered collection
+ event.filterMatchModes: Match modes per field - Callback to invoke on filtering. Page and Sort information is also available for lazy loading implementation. + Event to emit after filtering, not triggered in lazy mode. row-click diff --git a/src/views/datatable/DataTableFilterDemo.vue b/src/views/datatable/DataTableFilterDemo.vue index 62f708e4b7..6bf54ad235 100644 --- a/src/views/datatable/DataTableFilterDemo.vue +++ b/src/views/datatable/DataTableFilterDemo.vue @@ -13,7 +13,7 @@ @@ -58,7 +58,7 @@ <DataTable :value="cars" :filters="filters" :paginator="true" :rows="10"> <template #header> <div style="text-align: right"> - <i class="pi pi-search" style="margin: 4px 4px 0px 0px;"></i> + <i class="pi pi-search" style="margin: 4px 4px 0 0"></i> <InputText v-model="filters['global']" placeholder="Global Search" size="50" /> </div> </template>