Reputation: 143
I'm new in vaadin development and i hope someone can help me. I just created a grid table with a model and everything works fine. But now, i want to change the background color of the selected row. I figure out, that i have to create a theme. I found this in the Vaadin Forum: https://vaadin.com/forum/thread/17867059/how-to-set-selected-row-opacity-in-vaadin-grid
This is what i have already done:
Here is the code from the other thread in the forum:
<dom-module id="grid-header" theme-for="vaadin-grid">
<template>
<style>
:host(:not([reordering])) [part~="row"][selected] [part~="body-cell"]:not([part~="details-cell"]) {
background-color: rgba(255, 0, 0, .50);
}
</style>
</template>
</dom-module>
But it does not work.
Upvotes: 1
Views: 2206
Reputation: 2652
This seems to work fine for me, what is your version of framework?
In case you are using Vaadin 14, you would need to place styles into .css
file instead and import the file using @CSSImport
gridStyles.css
contains::host([theme~="grid-selection-theme"]) [part~="row"][selected] [part~="body-cell"]:not([part~="details-cell"]) {
background-color: red;
}
Class where grid is used has this import defined:
@CssImport(value = "./styles/gridStyles.css", themeFor = "vaadin-grid")
Grid has theme name added
I've change a host
selector to reflect a theme attribute: in case you have multiple grids on the same page, then style will be applied only to the one having mygrid.addThemeName("grid-selection-theme");
Upvotes: 7