Skip to content

Commit

Permalink
update both sides of pagination widget during changes (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacarar authored Jan 5, 2021
1 parent 216be53 commit 7e9a8fd
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1048,17 +1048,18 @@ export default {
},
changePage(value) {
if (this.paginationOptions.enabled) {
let paginationWidget = this.$refs.paginationBottom;
if (this.paginationOptions.position === 'top') {
paginationWidget = this.$refs.paginationTop;
let { enabled, position } = this.paginationOptions
let { paginationBottom, paginationTop } = this.$refs
if (enabled) {
if ((position === 'top' || position === 'both') && paginationTop) {
paginationTop.currentPage = value
}
if (paginationWidget) {
paginationWidget.currentPage = value;
// we also need to set the currentPage
// for table.
this.currentPage = value;
if ((position === 'bottom' || position === 'both') && paginationBottom) {
paginationBottom.currentPage = value
}
// we also need to set the currentPage
// for table.
this.currentPage = value;
}
},
Expand All @@ -1082,6 +1083,15 @@ export default {
perPageChanged(pagination) {
this.currentPerPage = pagination.currentPerPage;
// ensure that both sides of pagination are in agreement
// this fixes changes during position = 'both'
let paginationPosition = this.paginationOptions.position
if (this.$refs.paginationTop && (paginationPosition === 'top' || paginationPosition === 'both')) {
this.$refs.paginationTop.currentPerPage = this.currentPerPage
}
if (this.$refs.paginationBottom && (paginationPosition === 'bottom' || paginationPosition === 'both')) {
this.$refs.paginationBottom.currentPerPage = this.currentPerPage
}
//* update perPage also
const perPageChangedEvent = this.pageChangedEvent();
this.$emit('on-per-page-change', perPageChangedEvent);
Expand Down

0 comments on commit 7e9a8fd

Please sign in to comment.