[Feature Request] v-data-table: Add ability to set class and/or style per row.
See original GitHub issueProblem to solve
I want to set the row background color based on an item’s data field.
The only way to do that right now is to manually set the background for each column slot.
Proposed solution
Adding a row-class
and/or row-style
function could make it easy for user to have per-row control.
Example:
export default {
data() {
return {
rowClass: ({ item }) => this.getColor(item)
};
},
methods: {
getColor(calories) {
if (calories > 400) return "red";
else if (calories > 200) return "orange";
else return "green";
}
}
};
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How does one style a specific row on v-data-table? [Vuetify]
I want to change the tr background color do green. Sort of highlight it when ìtem.id_entry == lowestEntry["id_entry"] . javascript · vue.js ...
Read more >Data table component - Vuetify
The v-data-table component is used for displaying tabular data. Features include sorting, searching, pagination, content-editing, and row ...
Read more >Add dynamic filters to your data with ease, using Vue and the ...
This is a college admin dashboard, where the user can filter students suing various criteria. This is a single page web app, ...
Read more >How to create a Vuetify data table that has only some ...
Remove the show-expand prop from v-data-table , we're no longer using it. · Add :expanded. · Add a new column { text: '',...
Read more >Hazard Classification Guidance for Manufacturers, Importers ...
hazardous under the standard (except for chemicals OSHA has already determined to ... their search for available data for all hazard classes (see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with this being an issue - I need to adjust just the row css class (depending on an items value), and it appears the only solution is to switch to using item slots and defining all the table content myself, which is overkill.
I would like to resurrect this issue…
In my case, I want to allow users to change the columns’ positions, while also applying a custom class to rows depending on a property. If I redefine the entire row using the
item
slot, the table looses the ability to properly react to changes in theheaders
prop, i.e. whenheaders
is replaced with a new array sorted differently, the headers and the cells will not match anymore.Besides, having to redefine the way every column is rendered just to modify a small property of the row (which, I believe, is what @dasDaniel was referring to) is a complete overkill.