Fixed #27 - Reset DataTable page after sort

pull/41/head
cagataycivici 2019-07-28 17:11:23 +03:00
parent c7572be841
commit 2bc824e5b9
1 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,7 @@
<div class="p-datatable-header" v-if="$scopedSlots.header">
<slot name="header"></slot>
</div>
<DTPaginator v-if="paginatorTop" :rows="rows" :first="first" :totalRecords="totalRecordsLength" :pageLinkSize="pageLinkSize" :template="paginatorTemplate" :rowsPerPageOptions="rowsPerPageOptions"
<DTPaginator v-if="paginatorTop" :rows="d_rows" :first="d_first" :totalRecords="totalRecordsLength" :pageLinkSize="pageLinkSize" :template="paginatorTemplate" :rowsPerPageOptions="rowsPerPageOptions"
:currentPageReportTemplate="currentPageReportTemplate" class="p-paginator-top" @page="onPage($event)" :alwaysShow="alwaysShowPaginator">
<template #left v-if="$scopedSlots.paginatorLeft">
<slot name="paginatorLeft"></slot>
@ -61,7 +61,7 @@
</tr>
</tbody>
</table>
<DTPaginator v-if="paginatorBottom" :rows="rows" :first="first" :totalRecords="totalRecordsLength" :pageLinkSize="pageLinkSize" :template="paginatorTemplate" :rowsPerPageOptions="rowsPerPageOptions"
<DTPaginator v-if="paginatorBottom" :rows="d_rows" :first="d_first" :totalRecords="totalRecordsLength" :pageLinkSize="pageLinkSize" :template="paginatorTemplate" :rowsPerPageOptions="rowsPerPageOptions"
:currentPageReportTemplate="currentPageReportTemplate" class="p-paginator-bottom" @page="onPage($event)" :alwaysShow="alwaysShowPaginator">
<template #left v-if="$scopedSlots.paginatorLeft">
<slot name="paginatorLeft"></slot>
@ -283,6 +283,7 @@ export default {
},
onColumnHeaderClick(event, column) {
if (column.sortable) {
this.resetPage();
const targetNode = event.target;
const columnField = column.field || column.sortField;
@ -829,6 +830,10 @@ export default {
}
document.body.removeChild(link);
}
},
resetPage() {
this.d_first = 0;
this.$emit('update:first', this.d_first);
}
},
computed: {