I have a v-data-table with 5 columns, which some have predefined widths, and some don't.
I'd like only one line of text maximum for each item and display "..." when the text exceeds 1 line.
<v-data-table
dark
:footer-props="{ 'items-per-page-options': [10, 25, -1] }"
dense
calculate-widths
fixed-header
height="498"
:headers="headers"
hide-default-header
:items="res"
sort-by="publicationDate"
:sortDesc="sortVal"
>
<template v-slot:header="{ props: { headers } }">
<thead>
<tr>
<th v-for="h in headers" :class="h.class"
:key="h.text">
<span>{{h.text}}</span>
</th>
</tr>
</thead>
</template>
<template #item.video="{ item }">
<a
target="_blank"
v-if="item.video != ''"
class="links1 video-icon"
:href="item.video"
>
<v-btn dark icon>
<v-icon class="ic1">mdi-movie</v-icon>
</v-btn>
</a>
</template>
<template #item.title2="{ item }">
<a
target="_blank"
v-if="item.file != ''"
class="links1"
:href="item.file"
>
<span style="color:white"> {{ item.title }} </span>
</a>
</template>
</v-data-table>
I looked through the CSS properties to do so and I found things like :
text-overflow: ellipsis;
white-space: nowrap;
But it doesn't add the ... at the end of the lines and it also takes place beyond the widths applied to each columns so not all 5 columns are displayed on my panel.
Here's the headers in the data section
headers: [
{ text: "Source", value: "dataSource", width: "120px", class:"source-field"},
{ text: "News", value: "title2", width: "214px", class:"news-field"},
{ text: "Actors", value: "concernedActors", width: "242px" },
{ text: "Video", value: "video", width: "58px" },
{ text: "Publication", value: "publicationDate", width: "80px" },
],
And I tried this css but it won't work, the column news just goes bigger so that the entire text fits on 1 line.
th.news-field{
max-width: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
I would also love to make the hover darker on each line in the table
Here's a solution:
<template #item.foo="{ item }">
<div class="ellipsis-wrapper">{{ item.foo }}</div>
</template>
#your-table td {
position: relative;
}
#your-table td .ellipsis-wrapper {
position: absolute;
max-width: calc(100% - 1rem);
line-height: calc(3rem - 1px); /* change this if needed */
top: 0;
left: 1rem;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
But it creates another problem (easier to solve, IMHO): it takes the cell content out of the flow, therefore the table no longer calculates column width based on cells content (from the table's perspective, that column has no content) - so it relies on its header content (or on the provided width) to calculate the column width.
However, I believe making an "empty" column have a particular width (or a proportion from the table's width) is an easier to solve problem than your current one.
Demo: https://codepen.io/andrei-gheorghiu/pen/wvjoQXR
Related
the block code what i know how to add transition is
<tbody name="fade" is="transition-group">
<tr class="row" v-bind:key="item.data" v-if="item.more">
<td><p >{{k + 1}} - {{item.data}}</p></td>
</tr>
</tbody>
but how about vue-good-table anyone know the tricks to solve ?
in here, i only access the scss and
rowStyleClassFn the callback is set tr class='custom-transition'
<vue-good-table
:row-style-class="rowStyleClassFn" // the callback is set tr class='custom-transition'
...
>
...
// also i have tried with
<template slot="table-row" slot-scope="props">
<transition mode="out-in"> // i added looks like these
....
<span v-else>
<strong>{{ props.formattedRow[props.column.field] }}</strong>
</span>
</transition>
my scss
.yo-good-table::v-deep .vgt-table {
thead {
th {
border: $color-yo-border !important;
}
}
tbody {
tr.custom-transition {
transition: opacity 0.5s ease;
}
tr.custom-transition-active,
tr.custom-transition-leave-active {
transition: opacity 0.5s ease;
}
tr.custom-transition-enter-from,
tr.custom-transition-leave-to {
opacity: 0;
}
}
}
thanks in advance
My card hights is not displaying consistently as I intended. I was thinking to set the max-height to my v-card-text
<v-col cols="3" v-for="note in notes">
<v-card :loading="loading" max-width="374">
<template slot="progress">
<v-progress-linear color="deep-purple" height="10" indeterminate></v-progress-linear>
</template>
<v-img height="250" :src="note.img"></v-img>
<v-card-title>{{ note.name }}</v-card-title>
<v-card-text height="200px">
<div>{{ note.description }}</div>
</v-card-text>
<v-card-text>
<v-chip-group v-model="selection" active-class="deep-purple accent-4 white--text" column>
<v-chip v-for="tag in note.tag">
{{ tag }}
</v-chip>
</v-chip-group>
</v-card-text>
</v-card>
</v-col>
I see no effect
Any suggestions for me ?
You can achieve it with:
.v-card-text {
height: 200px;
overflow-y: auto;
}
If you don't want a scrollbar and you're fine with the text being cropped:
overflow-y: hidden;
Shortcomings:
.v-card-text will always have this height, even if all items on a row end up not using all of it
you might want to customise the scrollbar appearance on browsers which display a wide scrollbar (17px) on desktop (e.g: Chrome).
Alternatively, if you want the tallest card in each row to set the height (resulting in rows with cards of different heights) and not have any overflow, but have some white space on some cards instead, I can help you achieve it if you create a runnable snippet, so I can test. In principle, you need to give the card container display: flex; flex-direction: column; and give .v-card-text { flex-grow: 1 }.
In practice, the card might have more than one wrapper, which is why I need to see a live snippet, if you're interested in this solution.
I would like to add id elements to the next VUE templates. So, I can identify these html elements by their ids.
First scenario, I would like to add an id to the submit (ok) button
<core-dialog
v-if="deleteDialog.display"
v-model="deleteDialog.display"
type="confirmation"
width="500px"
:ok-button-text="$t('common.delete')"
#click:ok="
deleteDialog.display = false;
deleteDialog.rfqToDelete.remove({ shouldShowNotification: true });"
#click:cancel="cancelDelete"
>
On this second scenario, I would like to add an id on the footer element
<v-data-table
expand-icon="mdi-chevron-right"
style="border: solid 1px #e2e2e2; border-radius: 5px; margin: 0!important;min-width:900px "
data-cy="rfqs-table"
:headers="groupedByQuoteHeaders"
:items="loadedRfqs"
:item-class="itemRowBackground"
:loading="(isRfqsFindPending || isSearchPending )"
show-expand
:expanded.sync="expendRow"
item-key="_id"
:footer-props="{ 'items-per-page-text': $t('common.rowPerPageText'),
'page-text': `{0}-{1} ${$t('common.of')} {2}`}"
:no-results-text="$t('common.noDataAvailable')"
:no-data-text="$t('common.noDataAvailable')"
:loading-text="$t('common.loadingItems')"
#current-items="getFiltered"
#click:row="(item, slot) => slot.expand(!slot.isExpanded)"
#item-expanded="loadPart"
>
You could use a custom footer as the respective slot in the table component:
let tmpl = document.getElementById('tmpl-app')
new Vue({
el: '#app',
template: tmpl.content.cloneNode(true).innerHTML
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template id="tmpl-app">
<v-data-table
expand-icon="mdi-chevron-right"
style="border: solid 1px #e2e2e2; border-radius: 5px; margin: 0!important;min-width:900px "
data-cy="rfqs-table"
:headers="groupedByQuoteHeaders"
:items="loadedRfqs"
:item-class="itemRowBackground"
:loading="(isRfqsFindPending || isSearchPending )"
show-expand
:expanded.sync="expendRow"
item-key="_id"
:footer-props="{ 'items-per-page-text': $t('common.rowPerPageText'),
'page-text': `{0}-{1} ${$t('common.of')} {2}`}"
:no-results-text="$t('common.noDataAvailable')"
:no-data-text="$t('common.noDataAvailable')"
:loading-text="$t('common.loadingItems')"
#current-items="getFiltered"
#click:row="(item, slot) => slot.expand(!slot.isExpanded)"
#item-expanded="loadPart"
>
<div v-slot="footer" id="your-custom-id">
</div>
</v-data-table>
</template>
<div id="app"></div>
I want to remove icon in the v-expansion-panels.
and here is my codes in Vuejs
<v-card-text style="height: 300px;">
<v-card class="mx-auto mt-5" max-width="500" flat>
<v-row justify="center">
<v-expansion-panels popout>
<v-expansion-panel
v-for="(item,i) in 9"
:key="i"
>
<v-expansion-panel-header>Item</v-expansion-panel-header>
</v-expansion-panel>
</v-expansion-panels>
</v-row>
</v-card>
</v-card-text>
I tried these to remove icon..
.theme--light.v-expansion-panels .v-expansion-panel-header .v-expansion-panel-header__icon .v-icon {
color: white !important;
}
.mdi-chevron-down::before {
display: none !important;
}
.v-expansion-panel-header__icon {
display: none !important;
}
.v-icon notranslate mdi mdi-chevron-down theme--light {
display: none !important;
}
but none of them works.
how can I remove the icon? please help me..
Set the expand-icon prop of v-expansion-panel-header to an empty string
<v-expansion-panel-header expand-icon="">Item</v-expansion-panel-header>
Demo
Just add hide-actions to the panel-header
https://vuetifyjs.com/en/api/v-expansion-panel-header/#props
Just add the props: disable-icon-rotate
<v-expansion-panel-header disable-icon-rotate>Item</v-expansion-panel-header>
Good afternoon!
I would like a help to adjust the size of the block where the device, preferably I would like the box to be X px size or something like that. But you have other solution, I would want to see. I'm using vuetify.
enter image description here
<template v-slot:item.device="{ item }">
<v-chip>
{{ item.device }}
<v-icon small right #click.stop v-clipboard="item.uid" v-clipboard:success="showCopySnack">mdi-content-copy</v-icon>
</v-chip>
</template>
Add a class to the v-chip and wrap item.device in a span.
<v-chip class="short">
<span>{{item.device}}</span>
<v-icon small right #click.stop v-clipboard="item.uid" v-clipboard:success="showCopySnack">mdi-content-copy</v-icon>
</v-chip>
Then add css, where the v-chip class has the width and the span will ellipse.
.short{
width:100px;
}
.short span{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
codepen example