Fixed #163 - DataTable onPage event fires without sort and filter information

pull/201/head
cagataycivici 2020-01-30 12:06:16 +03:00
parent 5a546a356a
commit cf438de260
2 changed files with 51 additions and 22 deletions

View File

@ -451,9 +451,13 @@ export default {
this.d_first = event.first; this.d_first = event.first;
this.d_rows = event.rows; this.d_rows = event.rows;
let pageEvent = this.createLazyLoadEvent(event);
pageEvent.pageCount = event.pageCount;
pageEvent.page = event.page;
this.$emit('update:first', this.d_first); this.$emit('update:first', this.d_first);
this.$emit('update:rows', this.d_rows); this.$emit('update:rows', this.d_rows);
this.$emit('page', event); this.$emit('page', pageEvent);
}, },
onColumnHeaderClick(e) { onColumnHeaderClick(e) {
const event = e.originalEvent; const event = e.originalEvent;
@ -483,12 +487,7 @@ export default {
this.$emit('update:sortOrder', this.d_sortOrder); this.$emit('update:sortOrder', this.d_sortOrder);
this.$emit('update:multiSortMeta', this.d_multiSortMeta); this.$emit('update:multiSortMeta', this.d_multiSortMeta);
this.$emit('sort', { this.$emit('sort', this.createLazyLoadEvent(event));
originalEvent: event,
sortField: this.d_sortField,
sortOrder: this.d_sortOrder,
multiSortMeta: this.d_multiSortMeta
});
this.resetPage(); this.resetPage();
} }
@ -608,10 +607,9 @@ export default {
filteredValue = data; filteredValue = data;
} }
this.$emit('filter', { let filterEvent = this.createLazyLoadEvent(event);
filters: this.filters, filterEvent.filterValue = filteredValue;
filteredValue: filteredValue this.$emit('filter', filterEvent);
});
return filteredValue; return filteredValue;
}, },
@ -1598,6 +1596,18 @@ export default {
rows: this.rows * 2 rows: this.rows * 2
}); });
}, this.virtualScrollDelay); }, this.virtualScrollDelay);
},
createLazyLoadEvent(event) {
return {
originalEvent: event,
first: this.d_first,
rows: this.d_rows,
sortField: this.d_sortField,
sortOrder: this.d_sortOrder,
filters: this.filters,
globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
multiSortMeta: this.d_multiSortMeta
};
} }
}, },
computed: { computed: {

View File

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