Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update both sides of pagination widget during changes #769

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1043,17 +1043,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 @@ -1077,6 +1078,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