OnDemand
(Nico M)
November 27, 2024, 10:00am
1
Hi, i try to style my tree grid like following.
The red lines, should be completely red background (the exapanded once)
therefor i tried in vaadin-grid-layout.css
vaadin-grid::part(expanded-row){
color: var(--main-color);
font-width: 800;
}}
The header i would also like to change the background color.
Does anyone has an idea of whats going on? The doku mentioned that the expanded rows are vaadin-grid::part(collapsed-row)
but there is no hint to the header
rofa
(Rolf Smeds)
November 27, 2024, 10:19am
2
I’m guessing you’ve taken that expanded-row part name from the jsdoc rather than the online documentation? I recommend using the online styling docs instead: https://vaadin.com/docs/latest/components/grid/styling
Mentioned there, amongst other things, are:
Note: To set background colors based on row selectors, use the --vaadin-grid-cell-background
style property
and
vaadin-grid::part(expanded-row-cell)
So there’s two ways to apply background color:
Using vaadin-grid::part(expanded-row) { --vaadin-grid-cell-background: red; }
Using vaadin-grid::part(expanded-row-cell) { background: red; }
As for the header row, there’s vaadin-grid**::part(header-cell)**
(and btw the css color
property is for text color, not background color, and there is no such property as font-width
, perhaps you meant font-weight
?)
OnDemand
(Nico M)
November 27, 2024, 10:35am
3
Hi Rolf, oh yeah thank you! font-weight :D
That CSS works well, thank you!
OnDemand
(Nico M)
November 27, 2024, 11:22am
4
Is there also a way to let the values come in with an effect?
Each cell should be filled up a some seconds before the last one, is there a way? I think with javascript maybe or?
rofa
(Rolf Smeds)
November 27, 2024, 1:10pm
5
Unfortunately not really. Since the background is applied separately for each cell, there is no way to create an animation that swoops across them.
The reason for applying background separately on each cell is that the row doesn’t actually extend all the way to the end in a horizontally scrolling Grid. Theoretically you might be able to pull it off with a css animation, by setting the cell background transparent and applying an animated background on the row instead, if you know that your Grid will never scroll horizontally, but that seems a bit too hacky in my opinion.
OnDemand
(Nico M)
November 27, 2024, 1:20pm
6
Okay thank you. Is there a way to mark one row if it contains XY?
I have a column “marge” and the row with the lowest marge should be green. This should be possible anyhow right?
rofa
(Rolf Smeds)
November 27, 2024, 1:56pm
7
Yes, that’s described on the same page I linked to earlier: “Dynamically Styling Rows & Columns”
OnDemand
(Nico M)
November 27, 2024, 2:31pm
8
uh thanks works with setClassNamesGenerator i have used the deprecated one ;P