Cosmetics

pull/12/head
cagataycivici 2019-03-21 10:16:44 +03:00
parent 920c50aec1
commit e331c9fc4c
2 changed files with 12 additions and 8 deletions

View File

@ -45,7 +45,10 @@ export default {
type: Number, type: Number,
default: 5 default: 5
}, },
rowsPerPageOptions: Array, rowsPerPageOptions: {
type: Array,
default: null
},
template: { template: {
type: String, type: String,
default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown' default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown'
@ -66,7 +69,7 @@ export default {
}, },
computed: { computed: {
templateItems() { templateItems() {
var keys = []; let keys = [];
this.template.split(' ').map((value) => { this.template.split(' ').map((value) => {
keys.push(value.trim()); keys.push(value.trim());
}) })
@ -120,17 +123,18 @@ export default {
}, },
methods: { methods: {
changePage(first, rows) { changePage(first, rows) {
var pc = this.pageCount; const pc = this.pageCount;
var p = Math.floor(first / rows); const p = Math.floor(first / rows);
if(p >= 0 && p < pc) { if (p >= 0 && p < pc) {
var newPageState = { let newPageState = {
first: first, first: first,
rows: rows, rows: rows,
page: p, page: p,
pageCount: pc pageCount: pc
}; };
this.$emit('change', newPageState);
this.$emit('page-change', newPageState);
this.$emit('update:first', first); this.$emit('update:first', first);
this.$emit('update:rows', rows); this.$emit('update:rows', rows);
} }

View File

@ -12,7 +12,7 @@
<Paginator :first.sync="first" :rows.sync="rows" :totalRecords="totalRecords" :rowsPerPageOptions="[10,20,30]"></Paginator> <Paginator :first.sync="first" :rows.sync="rows" :totalRecords="totalRecords" :rowsPerPageOptions="[10,20,30]"></Paginator>
<h3>Custom Template</h3> <h3>Custom Template</h3>
<Paginator :first="first2" :rows="rows2" :totalRecords="totalRecords2" @change="onPageChangeCustom($event)" template="FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink"> <Paginator :first="first2" :rows="rows2" :totalRecords="totalRecords2" @page-change="onPageChangeCustom($event)" template="FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink">
<template #left> <template #left>
<Button type="button" icon="pi pi-refresh" /> <Button type="button" icon="pi pi-refresh" />
</template> </template>