Skip to content

Commit

Permalink
[fix] issues 838 and 845 with perPage option all = -1 (#857)
Browse files Browse the repository at this point in the history
* fix 838 and 845 with perPage option all = -1

* fix 838 and 485 - doc
  • Loading branch information
mp3000mp authored Sep 29, 2021
1 parent b56402d commit 733b28d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/guide/configuration/pagination-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
position: <span class="token punctuation">'</span>top<span class="token punctuation">'</span>
}<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>vue-good-table</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h2 id="perpage"><a href="#perpage" class="header-anchor">#</a> perPage</h2> <p>type: <code>Integer (default: 10)</code></p> <p>Number of rows to show per page</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>vue-good-table</span>
</code></pre></div><h2 id="perpage"><a href="#perpage" class="header-anchor">#</a> perPage</h2> <p>type: <code>Integer (default: 10)</code></p> <p>Number of rows to show per page. This option can be set to -1 to show all rows.</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>vue-good-table</span>
<span class="token attr-name">:columns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>columns<span class="token punctuation">&quot;</span></span>
<span class="token attr-name">:rows</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>rows<span class="token punctuation">&quot;</span></span>
<span class="token attr-name">:pagination-options</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>{
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ export default {
// calculate page end now
let pageEnd = paginatedRows.length + 1;
// if the setting is set to 'all'
// if the setting is not set to 'all'
if (this.currentPerPage !== -1) {
pageEnd = this.currentPage * this.currentPerPage;
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/pagination/VgtPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:value="option">
{{ option }}
</option>
<option v-if="paginateDropdownAllowAll" :value="total">{{allText}}</option>
<option v-if="paginateDropdownAllowAll" :value="-1">{{allText}}</option>
</select>
</form>
</div>
Expand Down Expand Up @@ -118,6 +118,10 @@ export default {
computed: {
// Number of pages
pagesCount() {
// if the setting is set to 'all'
if(this.currentPerPage === -1) {
return 1;
}
const quotient = Math.floor(this.total / this.currentPerPage);
const remainder = this.total % this.currentPerPage;
Expand Down
4 changes: 4 additions & 0 deletions src/components/pagination/VgtPaginationPageInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export default {
return ((this.currentPage - 1) * this.currentPerPage) + 1;
},
lastRecordOnPage() {
// if the setting is set to 'all'
if(this.currentPerPage === -1) {
return this.totalRecords;
}
return Math.min(this.totalRecords, this.currentPage * this.currentPerPage);
},
recordInfo() {
Expand Down

0 comments on commit 733b28d

Please sign in to comment.