Fixed #181 - DataTable "$event" argument on page/sort events does not contains filterSearchMode.

pull/193/head
cagataycivici 2020-02-07 10:23:19 +03:00
parent 0007663991
commit 68a8af7cb8
3 changed files with 25 additions and 15 deletions

View File

@ -608,7 +608,7 @@ export default {
} }
let filterEvent = this.createLazyLoadEvent(event); let filterEvent = this.createLazyLoadEvent(event);
filterEvent.filterValue = filteredValue; filterEvent.filteredValue = filteredValue;
this.$emit('filter', filterEvent); this.$emit('filter', filterEvent);
return filteredValue; return filteredValue;
@ -1598,15 +1598,25 @@ export default {
}, this.virtualScrollDelay); }, this.virtualScrollDelay);
}, },
createLazyLoadEvent(event) { createLazyLoadEvent(event) {
let filterMatchModes;
if (this.hasFilters) {
filterMatchModes = {};
this.columns.forEach(col => {
if (col.field) {
filterMatchModes[col.field] = col.filterMatchMode;
}
});
}
return { return {
originalEvent: event, originalEvent: event,
first: this.d_first, first: this.d_first,
rows: this.d_rows, rows: this.d_rows,
sortField: this.d_sortField, sortField: this.d_sortField,
sortOrder: this.d_sortOrder, sortOrder: this.d_sortOrder,
multiSortMeta: this.d_multiSortMeta,
filters: this.filters, filters: this.filters,
globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null, filterMatchModes: filterMatchModes
multiSortMeta: this.d_multiSortMeta
}; };
} }
}, },

View File

@ -1970,45 +1970,45 @@ export default {
<tbody> <tbody>
<tr> <tr>
<td>page</td> <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.first: Index of first record <br/>
event.rows: Number of rows to display in new page <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.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br /> event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br /> event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br /> event.filters: Collection of active filters <br />
event.filteredValue: Filtered collection event.filterMatchModes: Match modes per field
</td> </td>
<td>Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation.</td> <td>Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation.</td>
</tr> </tr>
<tr> <tr>
<td>sort</td> <td>sort</td>
<td>event.page: New page number <br/> <td>event.originalEvent: Browser event <br >
event.first: Index of first record <br/> event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <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.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br /> event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br /> event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br /> event.filters: Collection of active filters <br />
event.filteredValue: Filtered collection event.filterMatchModes: Match modes per field
</td> </td>
<td>Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation.</td> <td>Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation.</td>
</tr> </tr>
<tr> <tr>
<td>filter</td> <td>filter</td>
<td>event.page: New page number <br/> <td>event.originalEvent: Browser event <br >
event.first: Index of first record <br/> event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <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.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br /> event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br /> event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <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>
<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>
<tr> <tr>
<td>row-click</td> <td>row-click</td>

View File

@ -13,7 +13,7 @@
<DataTable :value="cars" :filters="filters" :paginator="true" :rows="10"> <DataTable :value="cars" :filters="filters" :paginator="true" :rows="10">
<template #header> <template #header>
<div style="text-align: right"> <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" /> <InputText v-model="filters['global']" placeholder="Global Search" size="50" />
</div> </div>
</template> </template>
@ -58,7 +58,7 @@
&lt;DataTable :value="cars" :filters="filters" :paginator="true" :rows="10"&gt; &lt;DataTable :value="cars" :filters="filters" :paginator="true" :rows="10"&gt;
&lt;template #header&gt; &lt;template #header&gt;
&lt;div style="text-align: right"&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;InputText v-model="filters['global']" placeholder="Global Search" size="50" /&gt;
&lt;/div&gt; &lt;/div&gt;
&lt;/template&gt; &lt;/template&gt;