Skip to content

Commit

Permalink
Fixed #181 - DataTable "$event" argument on page/sort events does not…
Browse files Browse the repository at this point in the history
… contains filterSearchMode.
  • Loading branch information
cagataycivici committed Feb 7, 2020
1 parent 0007663 commit 68a8af7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
16 changes: 13 additions & 3 deletions src/components/datatable/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ export default {
}
let filterEvent = this.createLazyLoadEvent(event);
filterEvent.filterValue = filteredValue;
filterEvent.filteredValue = filteredValue;
this.$emit('filter', filterEvent);
return filteredValue;
Expand Down Expand Up @@ -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
};
}
},
Expand Down
20 changes: 10 additions & 10 deletions src/views/datatable/DataTableDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1970,45 +1970,45 @@ export default {
<tbody>
<tr>
<td>page</td>
<td>event.page: New page number <br/>
<td>event.originalEvent: Browser event <br >
event.page: New page number <br/>
event.pageCount: Total page count <br/>
event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <br/>
event.pageCount: Total number of pages <br />
event.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br />
event.filteredValue: Filtered collection
event.filterMatchModes: Match modes per field
</td>
<td>Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation.</td>
</tr>
<tr>
<td>sort</td>
<td>event.page: New page number <br/>
<td>event.originalEvent: Browser event <br >
event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <br/>
event.pageCount: Total number of pages <br />
event.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br />
event.filteredValue: Filtered collection
event.filterMatchModes: Match modes per field
</td>
<td>Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation.</td>
</tr>
<tr>
<td>filter</td>
<td>event.page: New page number <br/>
<td>event.originalEvent: Browser event <br >
event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <br/>
event.pageCount: Total number of pages <br />
event.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br />
event.filteredValue: Filtered collection
event.filteredValue: Filtered collection <br />
event.filterMatchModes: Match modes per field
</td>
<td>Callback to invoke on filtering. Page and Sort information is also available for lazy loading implementation.</td>
<td>Event to emit after filtering, not triggered in lazy mode.</td>
</tr>
<tr>
<td>row-click</td>
Expand Down
4 changes: 2 additions & 2 deletions src/views/datatable/DataTableFilterDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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>
Expand Down Expand Up @@ -58,7 +58,7 @@
&lt;DataTable :value="cars" :filters="filters" :paginator="true" :rows="10"&gt;
&lt;template #header&gt;
&lt;div style="text-align: right"&gt;
&lt;i class="pi pi-search" style="margin: 4px 4px 0px 0px;"&gt;&lt;/i&gt;
&lt;i class="pi pi-search" style="margin: 4px 4px 0 0"&gt;&lt;/i&gt;
&lt;InputText v-model="filters['global']" placeholder="Global Search" size="50" /&gt;
&lt;/div&gt;
&lt;/template&gt;
Expand Down

0 comments on commit 68a8af7

Please sign in to comment.