-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I alternate background color of rows? #217
Comments
Hey! That's not so easy at the moment due to the nature how subtrees are rendered in a nested way, but a hacky solution would be to hook into context object from the tree environment, which contains a "linearItems" prop which contains a list of all tree items in a flattened order, which can be used to find out if an item is even or not. This can then be used in the item render logic to change the display behaviour. This is a bit inconsistent with updates, where opening a subtree doesn't always directly update the proper colors, so this might need some additional fiddeling to get right. |
Thanks for the reply. It looks a bit expensive to do the |
Yeah that is true. Another option might be to customize the styling afterwards with the DOM api.. [...document.getElementsByClassName("rct-tree-item-button")]
.filter((_, i) => i % 2 === 0)
.forEach(n => n.style.backgroundColor = "red") You would have to clean it up and rerun it every time the tree updates, so it's definitely far from elegant, but might be a feasible workaround since |
Has anyone successfully been able to alternate background colors for each row rendered? If so please share how you were able to achieve this. Thanks!
The text was updated successfully, but these errors were encountered: