KR1
May 2, 2023, 6:23pm
1
What I’m trying to do:
I want to change the color of every 2nd row of the repeating panel
What I’ve tried and what’s not working:
I think there is something missing after .repeating-panel to change the color. Studying html don’t help because I can’t find it. Does the panel has some other object than need to be targeted with CSS?
Code Sample:
.anvil-role-tonal-data-grid.anvil-data-grid .data-grid-child-panel > .repeating-panel > div:nth-of-type(even) {
background-color: %color:rows_tables% !important;
}
Clone link:
share a copy of your app
Here’s the CSS I use in a similar role (I can’t take credit for it, @stucork provided it in response to a similar question years ago):
.anvil-role-striped .anvil-data-row-panel:nth-child(even) {
background: #EEEEEE;
}
for the odd rows - one approach you could take would be to add this to your theme.css
.anvil-data-row-panel:nth-child(even) {
background: %color:Gray 200%;;
}
this would make all even rows gray for all anvil-row-panels
more advanced…
If you only wanted anvil-row-panels for some data grids gray - you could create an anvil role for the repeating panel called striped
https://anvil.works/docs/client/themes-and-styling#roles
.anvil-role-striped .anvil-data-row-panel:nth-child(even) {
…
3 Likes
KR1
May 3, 2023, 6:03am
3
Thanks for the linking the topic to me. I was looking for the syntax to get to the end.
In my code one > div >
was still missing. I missed that
.anvil-role-tonal-data-grid.anvil-data-grid .data-grid-child-panel > .repeating-panel > div > div:nth-of-type(even) {
background-color: %color:rows_tables% !important;
}
in my case I have to watch out. I’m using DataRowPanel already as header and need to style it one by one to avoid overwriting.
1 Like