v-data-table: add header parameter to control visibility
See original GitHub issueTo account for different viewing devices with varying screen dimensions, it is custom to show or hide columns in a table depending on the viewport width. Vuetify already offers classes to do so, which can easily be applied in the table items slot of <v-data-table>
:
<template slot="items" scope="props">
<td>{{ props.item.first_name }}</td>
<td>{{ props.item.last_name }}</td>
<td class="hidden-xs-only">{{ props.item.email }}</td>
<td class="hidden-xs-only">{{ props.item.phone }}</td>
<td class="hidden-sm-and-down">{{ props.item.country }}</td>
<td class="text-xs-right hidden-xs-only">{{ props.item.quotes_count }}</td>
</template>
However, for the table headers this is much more difficult to achieve. It is of course possible to create custom header markup which contains the display classes within <template slot="headers" scope="props">
, but, as far as I know, this also forces one to wire up all the code for pagination and sorting himself, instead of relying on the built-in features.
Would you think it is feasible and desirable to add an extra field to the header items object that controls for visibility? e.g.
headers: [
{
text: 'Contact',
value: 'contact.name',
align: 'left',
},
{
text: 'E-mail',
value: 'contact.email',
align: 'left',
visibility: 'hidden-sm-and-down'
},
{
text: 'Created',
value: 'created_at',
align: 'left',
visibility: 'hidden-xs-only'
}
],
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:9 (3 by maintainers)
Top GitHub Comments
I currently implemented this functionality with:
and for the header data:
So the only line that I think needs to be added to make this work in the internal header code of v-data-table is
to the header fields class definitions.
I would suggest naming the field
class
orclasses
instead ofvisibility
to make the solution more generic