I have the following table in which I can't align some items such as the checkbox and the actions:
This is the table:
<v-data-table
:headers="headers"
:items="users"
hide-actions
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td>{{ props.item.email }}</td>
<td class="text-xs-left">{{ props.item.empresa.descripcion}}</td>
<v-checkbox disabled v-model="props.item.isAdmin"></v-checkbox>
<td class="text-xs-left">{{ props.item.createdAt }}</td>
<td class="justify-center layout px-0">
<v-icon
small
class="mr-2"
#click="editItem(props.item)"
>
Editar
</v-icon>
<v-icon
small
left
class="mr-2"
#click="deleteItem(props.item)"
>
Eliminar
</v-icon>
</td>
</template>
</v-data-table>
I need to align the v-checkbox and the v-icon.
There is no css in the <style> section.
Give it a try wrapping the <v-layout justify-center></v-layout> with <td></td> like the Ohgodwhy comment.
It would be like:
<v-data-table
:headers="headers"
:items="users"
hide-actions
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td>
<v-layout justify-center>
{{ props.item.email }}
</v-layout>
</td>
<td>
<v-layout justify-center>
{{ props.item.empresa.descripcion}}
</v-layout>
</td>
<td>
<v-layout justify-center>
<v-checkbox disabled v-model="props.item.isAdmin"></v-checkbox>
</v-layout>
</td>
<td>
<v-layout justify-center>
{{ props.item.createdAt }}
</v-layout>
</td>
<td>
<v-layout justify-center>
<v-icon
small
class="mr-2"
#click="editItem(props.item)"
>
Editar
</v-icon>
<v-icon
small
left
class="mr-2"
#click="deleteItem(props.item)"
>
Eliminar
</v-icon>
</v-layout>
</td>
</template>
</v-data-table>
For those of you taking a simple example from the Vuetify docs like I did:
<v-card>
<v-card-title id="balloon-title">Balloon Info - tracking [balloon ID]</v-card-title>
<v-data-table disable-sort dense hide-default-footer :headers="headers" :items="info" item-key="name">
</v-data-table>
</v-card>
The solution above requires you to change your entire layout. Instead, I styled the td selector like so
td {
text-align: center !important;
}
Hope this helps!
edit- make sure this style isn't in a scoped component.
Here's a simplified snippet that iterates <td> instead of specifying each prop, using only the css class text-center instead of a whole v-layout component:
<v-data-table
item-key="yourItemKey"
:items="dataSet"
:headers="headers">
<!-- item is the row itself with the column values -->
<template v-slot:item="{ item }">
<tr>
<td v-for="(val, key) in item" :key="key" class="text-center">
{{ val }}
</td>
</tr>
</template>
</v-data-table>
Related
with vuetify 2.x, I´d like to show my data grouped with option to collapse and expand on icon click.
My problem is if I use both 'group.header slot' and 'group slot', the first one doesn´t appear in the table.
If I hide 'group.header' slot I can put the group name into 'group slot', but I can´t use the icon click to collapse/expand the group.
<v-card-text>
<v-data-table
:headers="headers_parcelas"
:items="fitens_parcelas"
:items-per-page="5"
dense
hide-default-header
group-by="nome_conta"
show-group-by
class="elevation-1 marcarguias"
>
<template #[`group.header`]="{ group, isOpen, toggle }">
<th colspan="2">
<v-icon #click="toggle"
>{{ isOpen ? 'mdi-minus' : 'mdi-plus' }}
</v-icon>
{{ group }}
</th>
</template>
<template #group="props">
<!-- <span class="font-weight-bold">
{{ props.group }}
</span> -->
<v-data-table
:headers="props.headers"
:items="props.items"
dense
item-key="nome_conta"
hide-default-footer
>
<template #body="{ items }">
<tbody>
<tr v-for="item in items" :key="item.id">
<td>{{ item.descricao }}</td>
<td>{{ item.nome_forma_recebimento }}</td>
<td>{{ item.nome_quem_lancou }}</td>
<td>
{{ formatCurrency(item.valor_recebido) }}
</td>
<td class="text-center">
<span>
<v-icon
small
title="Apagar Movimento"
color="error"
#click.stop="deleteParcelaCaixa(item)"
>
mdi-delete
</v-icon>
</span>
</td>
</tr>
<tr>
<td colspan="5" class="text-center">
<span class="ml-10 font-weight-black">
SubTotal: {{ formatCurrency(itemTotal(items)) }}
</span>
</td>
</tr>
</tbody>
</template>
</v-data-table>
</template>
<template #[`body.append`]="{ items }">
<v-col
cols="12"
sm="6"
class="text-center font-weight-black text-h6 primary mx-auto"
>
Total:{{ formatCurrency(getTotalCost(items)) }}
</v-col>
</template>
</v-data-table>
</v-card-text>```
I have a v-data-table in which I have the rows with checkboxes. I'm trying to implement a checkbox in the table header where selecting the checkbox would select the entire checkboxes in the table row.
This is my code:
<v-data-table
v-model="model"
styles="font-size:5px;"
:headers="headers"
:items="items"
single-select
:items-per-page="10"
class="elevation-1" hide-default footer
>
<template slot="headers" slot-scope="props">
<tr>
<th> <v-checkbox :input-value="props.all"> </v-checkbox>
</tr>
</template>
<template v-slot:item="row" :activator="{ on, attrs }">
<!-- <tr #click="highlightRow(item.item, item)"> -->
<tr>
<td>{{ row.item.DisplayValue }}</td>
<td>
<label class="form-checkbox">
<input type="checkbox" :value="row.item.DataValue" v-model="preselected1" >
<i class="form-icon"></i>
</label>
</td>
<td>
<label class="form-checkbox">
<input type="checkbox" :value="row.item.DataValue" v-model="preselected2">
<i class="form-icon"></i>
</label>
</td>
</tr>
</template>
</v-data-table>
I did try the solution from https://vuetifyjs.com/en/components/data-tables/#row-selection but what I'm trying to achieve is more like:
Need checkbox in highlighted places
Any pointers on achieving this would be appreciated.
According to Vuetify documentation, you can do something like this:
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
<template v-slot:header.colWithCheckbox_1="{ header }">
{{ header.text }}
<v-checkbox v-model="headerCheckboxes.colWithCheckbox_1" />
</template>
</v-data-table>
I am creating a web app which has a lot of tables that get rendered on the page, however I have noticed the performance of the web page reduces drastically the more I add. Especially when i zoom in and out, this causing the page to lag for a few seconds. Is there any way to work around this? I have heard lazy loading is a good method, however that seems like its only for initial loads.
<v-text-subtitle name="moaamlol6" class="blue--text"
>Mapping of Assessment Against Module Learning Outcomes - Level
6</v-text-subtitle
>
<v-dialog
v-model="dialogL6"
fullscreen
hide-overlay
transition="dialog-bottom-transition"
>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="red lighten-2"
dark
v-bind="attrs"
v-on="on"
outlined
>
Edit
</v-btn>
</template>
<v-card>
<v-toolbar dark color="primary">
<v-toolbar-title
>Mapping of Assessment Against Module Learning Outcomes -
Level 6</v-toolbar-title
>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn text dark #click="dialogL6 = false"> Cancel </v-btn>
<v-divider vertical></v-divider>
<v-btn dark text #click="generateL6"> Insert </v-btn>
</v-toolbar-items>
</v-toolbar>
<v-card-text style="display: inline-flex">
<div>
<table class="bordered" ref="L6">
<tr>
<th colspan="99">
Mapping of Assessment Against Module Learning Outcomes -
Level 6
</th>
</tr>
<tr>
<th rowspan="2">Module Assessment Elements</th>
<th colspan="99">Module Learning Outcomes</th>
</tr>
<tr>
<td v-for="index in numOfCLO" v-bind:key="index">
{{ index }}
</td>
</tr>
<tr v-for="y in specMod.length" v-bind:key="y">
<td>{{ specMod[y - 1].module_name }}</td>
<td
class="notclicked"
v-for="x in numOfCLO"
v-bind:key="x"
:id="x + '*' + y"
#click="changeClassL6(x, y)"
></td>
</tr>
</table>
</div>
<div>
<p v-html="courseDataJson[0].mapping_assessment_l6"></p>
</div>
</v-card-text>
</v-card>
</v-dialog>
<p
v-html="courseDataJson[0].mapping_assessment_l6"
v-if="dialogL6 == false"
></p>
I have 4x of these tables, however the performance is fine. But once I add the final table the performance tanks
<v-text-subtitle name="isfa" class="blue--text"
>Indicative Schedule for Assessment</v-text-subtitle
>
<table class="bordered" ref="indicative">
<tr>
<th colspan="99">Indicative Schedule for Assessment</th>
</tr>
<tr>
<th>Week</th>
<td>Level 3</td>
<td>Level 4</td>
<td>Level 5</td>
<td>Level 6</td>
<td>Level 7</td>
</tr>
<tr>
<th>TT</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr v-for="x in 52" :key="x">
<th>Week {{ x }}</th>
<td
v-for="y in 5"
:key="y"
#click="openDialog(x, y)"
class="clickable"
>
<div v-for="data in schedule_dataJson" v-bind:key="data.id">
<v-card
v-if="data.week == x && data.level == y + 2 && data.courseId == courseDataJson[0].id"
class="mt-2 mb-2"
color="#F5F5F5"
>
<v-toolbar :color="data.colour">
<v-toolbar-title>
<v-icon>{{ data.icon }}</v-icon> {{ data.name }} |
{{ data.location }}
</v-toolbar-title>
</v-toolbar>
<v-card-text v-if="data.note != null">
{{ data.note }}
</v-card-text>
</v-card>
</div>
</td>
</tr>
</table>
<v-dialog
v-model="dialog"
width="500"
height="1000"
persistent
transition="scale-transition"
>
<v-card>
<v-toolbar color="blue">
<v-toolbar-title>
Enter Schedule - Week {{ week }} - Level {{ level + 2 }}
</v-toolbar-title>
</v-toolbar>
<v-card-text
><v-select label="Icon" :items="items" v-model="icon">
<template slot="item" slot-scope="data">
<v-icon>{{ data.item }}</v-icon>
</template>
<template slot="selection" slot-scope="data">
<v-icon>{{ data.item }}</v-icon>
</template>
</v-select></v-card-text
>
<v-card-text
><v-text-field label="Select Name" v-model="name"></v-text-field
></v-card-text>
<v-card-text
>Select Colour:
{{ colour }}
<v-color-picker
class="ma-2"
dot-size="30"
v-model="colour"
:swatches="swatches"
show-swatches
hide-canvas
disabled
hide-inputs
></v-color-picker
></v-card-text>
<v-card-text
><v-text-field
label="Select Location"
v-model="location"
></v-text-field
></v-card-text>
<v-card-text>
<v-textarea auto-grow outlined label="Notes" v-model="note">
</v-textarea>
</v-card-text>
<v-divider></v-divider>
<v-card-subtitle
><v-btn text color="primary" #click="dialog2 = true"
>Existing Events</v-btn
></v-card-subtitle
>
<v-dialog
v-model="dialog2"
transition="slide-y-transition"
width="500"
height="1000"
persistent
>
<v-card>
<v-card-title class="pink lighten-2">
Delete Existing Events
</v-card-title>
<div v-for="data in schedule_dataJson" v-bind:key="data.test">
<v-toolbar
:color="data.colour"
v-if="data.week == week && data.level == level + 2"
>
<v-toolbar-title>
{{ data.name }} |
<v-icon>{{ data.icon }} | {{ data.id }} </v-icon>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn icon #click="deleted(data.id)"
><v-icon>mdi-delete</v-icon></v-btn
>
</v-toolbar-items>
</v-toolbar>
</div>
<v-divider></v-divider>
<v-card-actions>
<v-btn #click="dialog2 = false">close</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-divider></v-divider>
<v-card-actions>
<v-btn #click="dialog = false" color="primary" text
>Cancel</v-btn
>
<v-btn #click="insert" color="primary" text>Insert</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
I'm updating vuetify to the lastest version ( was 1.5 prior ) and I'm having trouble trying to adjust my table with the new props and slots. You can see my table right below, it has the possibility of selecting multiple lines and select all as well at the same time. I just need to purely replicate what I have, only to the new version and I don't know how to do it with the new slots.
<div class="col-12">
<v-data-table
v-model="selected"
:headers="headers"
:items="queriedData"
item-key="Id"
select-all
:pagination.sync="pagination"
:total-items="queriedData.lenght"
prev-icon="mdi-menu-left"
next-icon="mdi-menu-right"
sort-icon="mdi-menu-down"
>
<template v-slot:headers="props">
<tr>
<th v-if="canView">
<v-checkbox
:input-value="props.all"
:indeterminate="props.indeterminate"
primary
hide-details
color="white"
#click.stop="toggleAll"
class="table-checkbox-header"
></v-checkbox>
</th>
<th width="30px">
</th>
<th width="30px">
</th>
<th
v-for="header in props.headers"
:key="header.text"
:class="['column sortable', pagination.descending ? 'desc' : 'asc', header.value === pagination.sortBy ? 'active' : '']"
#click="changeSort(header.value)"
>
{{ header.text }}
<v-icon small>arrow_upward</v-icon>
</th>
</tr>
</template>
<template v-slot:no-data>
<div class="text-center">
{{NoInformation}}
</div>
</template>
<template v-slot:items="props">
<td v-if="canView">
<v-checkbox
v-model="props.selected"
primary
color="primary"
hide-details
class="table-checkbox-body"
></v-checkbox>
</td>
<td style="display: inline-flex;" >
<v-tooltip top color="primary" v-if="CanEdit">
<template v-slot:activator="{ on }">
<a v-on="on" class="btn-table-icon" #click.prevent="doSomething(props.item.Id)">
<i class="mdi mdi-eye icons-tables-margins"></i>
</a>
</template>
<span>{{view}}</span>
</v-tooltip>
<v-tooltip top color="primary" v-if="CanEdit" >
<template v-slot:activator="{ on }">
<a v-on="on" class="btn-table-icon" #click.prevent="doSomething(props.item.Id)">
<i class="mdi mdi-square-edit-outline icons-tables-margins"></i>
</a>
</template>
<span>{{view}}</span>
</v-tooltip>
</td>
<td>
<div v-if="props.item.Id!=0">
<span>Hello</span>
</div>
<div v-else>
<i class="mdi mdi-folder-lock-open"></i>
</div>
</td>
<td>{{ props.item.Name}}</td>
<td>{{ props.item.Name2}}</td>
<td>{{ props.item.Name3}}</td>
<td>{{ props.item.Name4}}</td>
<td :style="'color:' + props.item.ColorName" >{{ props.item.Name5}}</td>
</template>
</v-data-table>
</div>
Thank you.
Using slots seems not very different with the new version.
The only difference I can see is the props:
Before :
<template v-slot:headers="props">
Now :
<template v-slot:headers="{props}">
And for the checkboxes, you can just use the prop 'show-select' instead of using slots
I'm trying to show all the users that I have in Firebase, inside a v-data-table, but all the rows are shown in a single row.
<v-data-table
:headers="headers"
:items="users"
:loading="loading"
class="elevation-1"
:no-data-text="$t('admin.usersTable.empty')"
>
<template slot="item" slot-scope="props">
<td class="text-xs-right">{{ props.item.uid }}</td>
<td class="text-xs-right">{{ props.item.email }}</td>
<td class="text-xs-right">{{ props.item.username }}</td>
<td class="justify-center layout px-0">
<v-btn icon class="mx-0" #click="editUser(props.item)">
<v-icon color="teal">edit</v-icon>
</v-btn>
<v-btn icon class="mx-0" #click="removeUser(props.item)">
<v-icon color="pink">delete</v-icon>
</v-btn>
</td>
</template>
</v-data-table>
I expect the three users in a three different rows, but the result is that I have the users in one row
Maybe you should add a "s" in the word "item" ?
Like that :
<template slot="items" slot-scope="props">