question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] v-data-table: Add ability to set class and/or style per row.

See original GitHub issue

Problem 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:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

37reactions
gatkinsNZcommented, Nov 21, 2019

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.

12reactions
inad9300commented, Nov 4, 2019

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 theitem slot, the table looses the ability to properly react to changes in the headers prop, i.e. when headers 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found