简体   繁体   中英

How to set cell color in Vaadin 8 Grid only if row is not selected

I have:

grid.addColumn(...).setStyleGenerator(item -> "myCssDefinition");

were myCssDefinition is:

.v-grid-cell.myCssDefinition 
{
    color: red;
}

This works great except it makes the text almost impossible to read when the row is selected.

Therefore my question is how can I only change the style, or maybe it's how do I edit the style itself, so that the font color is ONLY red when the row is NOT selected, and when it's selected I just want to use the default Vaadin theme style.

You can use the following CSS to apply your styling to only not selected rows.

:not(.v-grid-row-selected) > .v-grid-cell.myCssDefinition {
    color: red;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM