I'm working with v-data-tables of Vuetify and....
I want to change this text:
I have added this code but it isn't working:
Thanks!
I'm working with v-data-tables of Vuetify and....
I want to change this text:
I have added this code but it isn't working:
Thanks!
You could use 'items-per-page-text':'products per page'
:
<v-data-table
:headers="headers"
:items="desserts"
:items-per-page="5"
item-key="name"
class="elevation-1"
:footer-props="{
showFirstLastPage: true,
firstIcon: 'mdi-arrow-collapse-left',
lastIcon: 'mdi-arrow-collapse-right',
prevIcon: 'mdi-minus',
nextIcon: 'mdi-plus',
'items-per-page-text':'products per page'
}"
></v-data-table>
Please check this example
page-text
which has by default $vuetify.dataFooter.pageText
as value but i don't know how could i change it –
Utimer 'page-text':'$vuetify.dataFooter.pageText'.replace('of','de')
but with no success –
Utimer The correct prop for Vuetify 2.X is items-per-page-text:
<v-data-table
:footer-props="{itemsPerPageText: 'Rows count'}"
></v-data-table>
:footer-props="{ pageText: '{0}-{1} de {2}' }
–
Fogdog <template v-slot:[`footer.page-text`]="items">
{{ items.pageStart }} - {{ items.pageStop }} de {{ items.itemsLength }}
</template>
Very simple, at least in version 3.3.9:
<VDataTable :pageText="'{0}-{1} de {2}'" />
The best way I've ever found is language localization in the Vuetify configuration.
import en from "vuetify/lib/locale/en";
export default new Vuetify({
theme: {
themes: {
options: {/*...*/},
light: {/*...*/},
dark: {/*...*/},
},
},
lang: {
locales: { en },
current: "en",
},
});
The above configuration causes all the Vuetify components (v-data-table
) to be language localized.
To change the "{start}-{end} of {total}, here's what I did: (the others solution didn't work)
<template>
<v-data-table
v-model:page="page"
v-model:items-per-page="itemsPerPage"
:items-per-page-text="$t('table.itemsPerPage')"
:page-text="pageText"
></v-data-table>
</template>
<script>
// Inside component definition
data() {
return {
items: [], // Array to show in the table
page: 1,
itemsPerPage: 5,
}
},
computed: {
pageText(): string {
const total = this.items.length
const startInterval = (this.page - 1)*this.itemsPerPage+1
const endInterval = Math.min(this.page*this.itemsPerPage, total)
const interval = `${startInterval}-${endInterval}`
return this.$t('table.pageText', {interval: interval, total:total})
}
},
</script>
And in my translation files, I have
en.json
{
"table": {
"itemsPerPage": "Items per page",
"pageText": "{interval} of {total}"
}
}
fr.json
{
"table": {
"itemsPerPage": "Items par page",
"pageText": "{interval} de {total}"
}
}
It's very simple in version 3.5.6:
<v-data-table
items-per-page-text="products per page"
/>
The uniqui way that works to me:
<v-data-table-server
v-model:items-per-page="itemsPerPage" // quantity of items
:items-per-page-options="[10, 25, 50, 100]" // options to select
:items-per-page-text="'Itens por página'" // translate text
:pageText="'{0}-{1} de {2}'" // translate quantity
:headers="headers"
:items-length="totalItems"
:items="items.results"
:loading="isLoading"
:search="search"
item-value="name"
@update:options="loadItems"
> </v-data-table-server>
© 2022 - 2024 — McMap. All rights reserved.