Fixed #230 - More options for currentPageReportTemplate
parent
876c96f2b9
commit
ee76fbb1c9
|
@ -5,8 +5,26 @@
|
||||||
export default {
|
export default {
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
pageCount: Number,
|
pageCount: {
|
||||||
page: Number,
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
first: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
rows: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
totalRecords: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
template: {
|
template: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '({currentPage} of {totalPages})'
|
default: '({currentPage} of {totalPages})'
|
||||||
|
@ -14,7 +32,15 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
text() {
|
text() {
|
||||||
return this.template.replace("{currentPage}", this.page + 1).replace("{totalPages}", this.pageCount);
|
let text = this.template
|
||||||
|
.replace("{currentPage}", this.page + 1)
|
||||||
|
.replace("{totalPages}", this.pageCount)
|
||||||
|
.replace("{first}", this.first + 1)
|
||||||
|
.replace("{last}", Math.min(this.first + this.rows, this.totalRecords))
|
||||||
|
.replace("{rows}", this.rows)
|
||||||
|
.replace("{totalRecords}", this.totalRecords);
|
||||||
|
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
<NextPageLink v-else-if="item === 'NextPageLink'" :key="item" @click="changePageToNext($event)" :disabled="isLastPage" />
|
<NextPageLink v-else-if="item === 'NextPageLink'" :key="item" @click="changePageToNext($event)" :disabled="isLastPage" />
|
||||||
<LastPageLink v-else-if="item === 'LastPageLink'" :key="item" @click="changePageToLast($event)" :disabled="isLastPage" />
|
<LastPageLink v-else-if="item === 'LastPageLink'" :key="item" @click="changePageToLast($event)" :disabled="isLastPage" />
|
||||||
<PageLinks v-else-if="item === 'PageLinks'" :key="item" :value="pageLinks" :page="page" @click="changePageLink($event)" />
|
<PageLinks v-else-if="item === 'PageLinks'" :key="item" :value="pageLinks" :page="page" @click="changePageLink($event)" />
|
||||||
<CurrentPageReport v-else-if="item === 'CurrentPageReport'" :key="item" :template="currentPageReportTemplate" :page="page" :pageCount="pageCount" />
|
<CurrentPageReport v-else-if="item === 'CurrentPageReport'" :key="item" :template="currentPageReportTemplate"
|
||||||
<RowsPerPageDropdown v-else-if="item === 'RowsPerPageDropdown' && rowsPerPageOptions" :key="item" :rows="d_rows" :options="rowsPerPageOptions" @rows-change="onRowChange($event)" />
|
:page="page" :pageCount="pageCount" :first="d_first" :rows="d_rows" :totalRecords="totalRecords" />
|
||||||
|
<RowsPerPageDropdown v-else-if="item === 'RowsPerPageDropdown' && rowsPerPageOptions" :key="item" :rows="d_rows"
|
||||||
|
:options="rowsPerPageOptions" @rows-change="onRowChange($event)" />
|
||||||
</template>
|
</template>
|
||||||
<div class="p-paginator-right-content" v-if="$scopedSlots.right">
|
<div class="p-paginator-right-content" v-if="$scopedSlots.right">
|
||||||
<slot name="right" :state="currentState"></slot>
|
<slot name="right" :state="currentState"></slot>
|
||||||
|
|
|
@ -52,10 +52,18 @@ import Paginator from 'primevue/paginator';
|
||||||
<li>CurrentPageReport</li>
|
<li>CurrentPageReport</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<CodeHighlight>
|
<h3>CurrentPageReport</h3>
|
||||||
<Paginator :first.sync="offset" :rows="10" :totalRecords="totalItemsCount"
|
<p>Current page report item in the itemplate displays information about the pagination state. Default value is ({currentPage} of {totalPages})
|
||||||
template="FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink"></Paginator>
|
whereas available placeholders are the following;
|
||||||
</CodeHighlight>
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>{currentPage}</li>
|
||||||
|
<li>{totalPages}</li>
|
||||||
|
<li>{rows}</li>
|
||||||
|
<li>{first}</li>
|
||||||
|
<li>{last}</li>
|
||||||
|
<li>{totalRecords}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h3>Custom Content</h3>
|
<h3>Custom Content</h3>
|
||||||
<p>There are two templates available named "left" and "right" to add custom content to these locations. Both templates get
|
<p>There are two templates available named "left" and "right" to add custom content to these locations. Both templates get
|
||||||
|
@ -65,9 +73,9 @@ import Paginator from 'primevue/paginator';
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<Paginator :first.sync="offset" :rows="10" :totalRecords="totalItemsCount">
|
<Paginator :first.sync="offset" :rows="10" :totalRecords="totalItemsCount">
|
||||||
<template #left="slotProps">
|
<template #left="slotProps">
|
||||||
Page: {{slotProps.state.page}}
|
Page: {{slotProps.state.page}}
|
||||||
First: {{slotProps.state.first}}
|
First: {{slotProps.state.first}}
|
||||||
Rows: {{slotProps.state.rows}}
|
Rows: {{slotProps.state.rows}}
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<Button type="button" icon="pi pi-search" />
|
<Button type="button" icon="pi pi-search" />
|
||||||
|
@ -142,8 +150,10 @@ onPage(event) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>currentPageReportTemplate</td>
|
<td>currentPageReportTemplate</td>
|
||||||
<td>string</td>
|
<td>string</td>
|
||||||
<td>({currentPage} of {totalPages})</td>
|
<td>({currentPage} of {totalPages})</td>
|
||||||
<td>Template of the current page report element.</td>
|
<td>Template of the current page report element. Available placeholders are
|
||||||
|
{currentPage},{totalPages},{rows},{first},{last} and {totalRecords}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>alwaysShow</td>
|
<td>alwaysShow</td>
|
||||||
|
|
Loading…
Reference in New Issue