Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i change label "Sort by" in Vuetify's data table?

The label is visible only in the mobile view at the top of the v-data-table. I've read the documentation and there's no such a prop that can modify the "Sort by" label.

like image 712
frontrk Avatar asked Jun 04 '20 09:06

frontrk


Video Answer


1 Answers

We can easily do this by adding headerProps to the data option like:

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data () {
    return {
      headerProps: {
        sortByText: "Custom Sort By Text"
      },
      headers: [
        //...
      ],
      items: [
        //...
      ]  
    }
  },
})

and then updating the template like:

<v-data-table
  :headers="headers"
  :items="items"
  :items-per-page="5"
  class="elevation-1"
  :header-props="headerProps"
>      
</v-data-table>

Now, in mobile view instead of showing default "Sort by" label, it will show "Custom Sort By Text" and you can modify it as you need.

like image 86
palaѕн Avatar answered Nov 10 '22 23:11

palaѕн