Skip to content

Commit

Permalink
fix for bug when using custom perPage dropdown with a custom perPage …
Browse files Browse the repository at this point in the history
…property
  • Loading branch information
xaksis committed Aug 25, 2018
1 parent db397f4 commit 2c7ab02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
7 changes: 6 additions & 1 deletion dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
:fixed-header="true"
max-height="300px"
:line-numbers="true"
:pagination-options="{ mode: 'pages', enabled: true, perPage: 5}"
:pagination-options="{
mode: 'pages',
enabled: true,
perPage: 2,
perPageDropdown: [3, 5, 9],
}"
:select-options="{
enabled: false,
selectOnCheckboxOnly: false,
Expand Down
20 changes: 12 additions & 8 deletions src/components/VgtPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export default {
if (event) {
this.currentPerPage = parseInt(event.target.value, 10);
}
if (this.currentPerPage === -1) {
if (this.currentPerPage === -1
|| this.total < this.currentPerPage * this.currentPage) {
// reset current page to 1
this.currentPage = 1;
}
Expand All @@ -182,7 +183,16 @@ export default {
},
handlePerPage() {
this.rowsPerPageOptions = cloneDeep(this.defaultRowsPerPageDropdown);
//* if there's a custom dropdown then we use that
if (this.customRowsPerPageDropdown !== null
&& (Array.isArray(this.customRowsPerPageDropdown)
&& this.customRowsPerPageDropdown.length !== 0)) {
this.rowsPerPageOptions = this.customRowsPerPageDropdown;
} else {
//* otherwise we use the default rows per page dropdown
this.rowsPerPageOptions = cloneDeep(this.defaultRowsPerPageDropdown);
}
if (this.perPage) {
this.currentPerPage = this.perPage;
// if perPage doesn't already exist, we add it
Expand All @@ -197,12 +207,6 @@ export default {
// reset to default
this.currentPerPage = 10;
}
if (this.customRowsPerPageDropdown !== null
&& (Array.isArray(this.customRowsPerPageDropdown)
&& this.customRowsPerPageDropdown.length !== 0)) {
this.rowsPerPageOptions = this.customRowsPerPageDropdown;
}
},
},
Expand Down

0 comments on commit 2c7ab02

Please sign in to comment.