From 91a890ea2548b959eeda9944b0e862d64d6066e0 Mon Sep 17 00:00:00 2001 From: Akshay Anand Date: Sun, 28 Mar 2021 13:28:29 -0400 Subject: [PATCH] fixes #837 - correct firstRecordOnPage --- dev/App.vue | 187 +++++++++--------- .../pagination/VgtPaginationPageInfo.vue | 9 +- 2 files changed, 101 insertions(+), 95 deletions(-) diff --git a/dev/App.vue b/dev/App.vue index 403fe23d..c9760afb 100644 --- a/dev/App.vue +++ b/dev/App.vue @@ -60,7 +60,7 @@ export default { perPage: 3, perPageDropdown: [3, 5, 10, 200, 300, 500, 1000], perPageDropdownEnabled: true, - // infoFn: (params) => `alala ${params.firstRecordOnPage} to ${params.lastRecordOnPage} of ${params.totalRecords}`, + infoFn: (params) => `alala ${params.firstRecordOnPage} to ${params.lastRecordOnPage} of ${params.totalRecords}`, }, columns: [ { @@ -143,98 +143,99 @@ export default { }, } ], - rows: [ - // { id:1, name:"John", age: 20, createdAt: '2018-02-18T00:00:43-05:00',score: 0.03343 }, - { - id: 2, - name: 'Jane', - age: 24, - createdAt: '2011-10-31', - score: 0.03343, - bool: true, - exact: 'match', - average: 1 - }, - { - id: 3, - name: 'Angel', - age: 16, - createdAt: '2011-10-30', - score: 0.03343, - bool: true, - exact: 'match', - average: null - }, - { - id: 4, - name: 'Chris', - age: 55, - createdAt: '2011-10-11', - score: 0.03343, - bool: false, - exact: null - }, - { - id: 5, - name: 'Dan', - age: 40, - createdAt: '', - score: 0.03343, - bool: null, - exact: 'rematch', - average: 2 - }, - { - id: 5, - name: '193.23', - age: 20, - createdAt: null, - score: 0.03343, - bool: null, - exact: 'rematch', - average: 3 - }, - { - id: 5, - name: 'Dan', - age: 34, - createdAt: null, - score: 0.03343, - bool: null, - exact: null, - average: 2 - }, - { - id: 6, - name: 'John', - age: 20, - createdAt: '2011-10-31', - score: 0.03343, - bool: true, - exact: 'match', - average: 1.5 - }, - { - id: 7, - name: 'Ángel', - age: 20, - createdAt: '2013-09-21', - score: null, - bool: 'false', - exact: null, - average: 1 - }, - { - id: 8, - name: 'Susan', - age: 16, - createdAt: '2013-10-31', - score: 0.03343, - bool: true, - exact: 'rematch', - average: 1 - }, - ], + rows: [], + // rows: [ + // // { id:1, name:"John", age: 20, createdAt: '2018-02-18T00:00:43-05:00',score: 0.03343 }, + // { + // id: 2, + // name: 'Jane', + // age: 24, + // createdAt: '2011-10-31', + // score: 0.03343, + // bool: true, + // exact: 'match', + // average: 1 + // }, + // { + // id: 3, + // name: 'Angel', + // age: 16, + // createdAt: '2011-10-30', + // score: 0.03343, + // bool: true, + // exact: 'match', + // average: null + // }, + // { + // id: 4, + // name: 'Chris', + // age: 55, + // createdAt: '2011-10-11', + // score: 0.03343, + // bool: false, + // exact: null + // }, + // { + // id: 5, + // name: 'Dan', + // age: 40, + // createdAt: '', + // score: 0.03343, + // bool: null, + // exact: 'rematch', + // average: 2 + // }, + // { + // id: 5, + // name: '193.23', + // age: 20, + // createdAt: null, + // score: 0.03343, + // bool: null, + // exact: 'rematch', + // average: 3 + // }, + // { + // id: 5, + // name: 'Dan', + // age: 34, + // createdAt: null, + // score: 0.03343, + // bool: null, + // exact: null, + // average: 2 + // }, + // { + // id: 6, + // name: 'John', + // age: 20, + // createdAt: '2011-10-31', + // score: 0.03343, + // bool: true, + // exact: 'match', + // average: 1.5 + // }, + // { + // id: 7, + // name: 'Ángel', + // age: 20, + // createdAt: '2013-09-21', + // score: null, + // bool: 'false', + // exact: null, + // average: 1 + // }, + // { + // id: 8, + // name: 'Susan', + // age: 16, + // createdAt: '2013-10-31', + // score: 0.03343, + // bool: true, + // exact: 'rematch', + // average: 1 + // }, + // ], }; }, methods: { diff --git a/src/components/pagination/VgtPaginationPageInfo.vue b/src/components/pagination/VgtPaginationPageInfo.vue index a05660c3..92e2b260 100644 --- a/src/components/pagination/VgtPaginationPageInfo.vue +++ b/src/components/pagination/VgtPaginationPageInfo.vue @@ -83,9 +83,14 @@ export default { return `${first} - ${last} ${this.ofText} ${this.totalRecords}`; }, infoParams() { + let first = this.firstRecordOnPage; + const last = this.lastRecordOnPage; + if (last === 0) { + first = 0; + } return { - firstRecordOnPage: this.firstRecordOnPage, - lastRecordOnPage: this.lastRecordOnPage, + firstRecordOnPage: first, + lastRecordOnPage: last, totalRecords: this.totalRecords, currentPage: this.currentPage, totalPages: this.lastPage,