Skip to content

Commit 30c0698

Browse files
committed
feat(QTable): Ability to use "pagination" without sync modifier for the initial state; rowsPerPage is by default first from rowsPerPageOptions quasarframework#7065
1 parent 074d48f commit 30c0698

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

ui/dev/src/pages/components/data-table-part1.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
bordered
143143
flat
144144
binary-state-sort
145-
:rows-per-page-options="[]"
145+
:pagination="{rowsPerPage: 3}"
146+
:rows-per-page-options="[1, 2, 3, 4, 6]"
146147
row-key="name"
147148
>
148149
<template v-slot:body="props">

ui/src/components/table/QTable.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ export default Vue.extend({
107107

108108
data () {
109109
return {
110-
innerPagination: {
110+
innerPagination: Object.assign({
111111
sortBy: null,
112112
descending: false,
113113
page: 1,
114-
rowsPerPage: 5
115-
}
114+
rowsPerPage: this.rowsPerPageOptions.length > 0
115+
? this.rowsPerPageOptions[0]
116+
: 5
117+
}, this.pagination)
116118
}
117119
},
118120

ui/src/components/table/table-pagination.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ function fixPagination (p) {
2020
export default {
2121
props: {
2222
pagination: Object,
23+
initialPagination: Object,
2324
rowsPerPageOptions: {
2425
type: Array,
25-
default: () => [3, 5, 7, 10, 15, 20, 25, 50, 0]
26+
default: () => [5, 7, 10, 15, 20, 25, 50, 0]
2627
}
2728
},
2829

2930
computed: {
3031
computedPagination () {
31-
return fixPagination({
32-
...this.innerPagination,
33-
...this.pagination
34-
})
32+
const pag = this.qListeners['update:pagination'] !== void 0
33+
? { ...this.innerPagination, ...this.pagination }
34+
: this.innerPagination
35+
36+
return fixPagination(pag)
3537
},
3638

3739
firstRowIndex () {
@@ -113,7 +115,7 @@ export default {
113115
return
114116
}
115117

116-
if (this.pagination) {
118+
if (this.pagination && this.qListeners['update:pagination'] !== void 0) {
117119
this.$emit('update:pagination', newPagination)
118120
}
119121
else {
@@ -137,6 +139,8 @@ export default {
137139
},
138140

139141
created () {
140-
this.$emit('update:pagination', { ...this.computedPagination })
142+
if (this.qListeners['update:pagination'] !== void 0) {
143+
this.$emit('update:pagination', { ...this.computedPagination })
144+
}
141145
}
142146
}

0 commit comments

Comments
 (0)