You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiDataGrid] Provide a way to highlight a row #4401
Currently, if you want to highlight a row in data grid you've to implement this in each cell like this:
It would be convenient and more effective (less operations) if one could do this per row and not per cell. Maybe data grid could provide a callback triggered by each row that allows the user to add / remove CSS classNames? This would be a flexible way to style a whole row.
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
Hi @snide, this enhancement would be a boon for Observability (and Discover I guess) to easily show row selection for the document/alert flyout. Would you have an ETA for this?
this enhancement would be a boon for Observability (and Discover I guess) to easily show row selection for the document/alert flyout. Would you have an ETA for this?
Quick update to this: #5515 incidentally adds the ability to quickly target all cells in a row with the following data attribute(s):
document.querySelectorAll('[data-gridcell-row-index="0"]');// Row index from your data array, not affected by sorting or paginationdocument.querySelectorAll('[data-gridcell-visible-row-index="0"]');// Visible row index of rendered grid, affected by sorting and pagination
Note that this is primarily a vanilla JS workaround for grabbing cells by row that may help folks in the interim. It doesn't provide a React first-party API/prop for rendering specific rows and does not close out/resolve this issue. It also does not resolve the background image issue in the issue description.
On that front: while we implemented wrapping row DOM nodes in #5285, the DOM nodes primarily are there for accessibility and don't actually function as wrappers (they render with 0 height and have no actual visible DOM rendering). This is because react-window virtualization library absolutely positions all its cells - updating our added row nodes to have matching positions, height, and width would be a moderate lift. It's doable, but it's not a trivial effort unfortunately and is something that would need to be scoped out/put on the roadmap.
You could do that now currently with CSS and data-attr targets, I don't think emotion would significantly change that lift.
Unfortunately, one of the specific requests for rows is that styling every cell in a row doesn't work for users who want a repeating background image to not break between cells, e.g.
Me: This is a non-trivial effort
Also me: I'm bored on a Thursday afternoon, let's see if I can solve the row issue
Good news @kertal@claudiopro@machadoum - the PR #5555 gets our row DOM working, and from there on it's much easier to implement an API for the desired functionality. Example screencap (the CSS being applied is the .euiMark class):
The area where I could use your help/feedback is the API that consumers use to pass custom classes/styling to specific rows. My proposal is adding an API to the current gridStyle prop that looks like this:
<EuiDataGrid// ... required propsgridStyle={{rowClasses: {0: 'someClass',// the first row will receive the `someClass` class1: 'anotherClass',5: 'etc',}}}/>
I tried to keep the data structure intentionally similar to rowHeightsOptions. However, my question for you all is whether this is flexible enough for the use case you are looking for or if you need more than this. Do you need the ability to pass any kind of prop (e.g. data attributes, inline styles, etc.) to rows? Or is just CSS classes sufficient for styling/appearances?
Quick note - in terms of considering our future move to css-in-js, I believe emotion allows passing in class names via a render prop, so I think you will still be able to use emotion and the class paradigm with this API. LMK if that sounds incorrect to you.
Me: This is a non-trivial effort Also me: I'm bored on a Thursday afternoon, let's see if I can solve the row issue
I scheduled some "boredom" to follow up on EUI issues :)
Good news @kertal@claudiopro@machadoum - the PR #5555 gets our row DOM working, and from there on it's much easier to implement an API for the desired functionality. Example screencap (the CSS being applied is the .euiMark class):
Looking good 👍
The area where I could use your help/feedback is the API that consumers use to pass custom classes/styling to specific rows. My proposal is adding an API to the current gridStyle prop that looks like this:
<EuiDataGrid// ... required propsgridStyle={{rowClasses: {0: 'someClass',// the first row will receive the `someClass` class1: 'anotherClass',5: 'etc',}}}/>
I tried to keep the data structure intentionally similar to rowHeightsOptions.
Also looking good 👍
However, my question for you all is whether this is flexible enough for the use case you are looking for or if you need more than this. Do you need the ability to pass any kind of prop (e.g. data attributes, inline styles, etc.) to rows? Or is just CSS classes sufficient for styling/appearances?
For me CSS classes work fine, I wouldn't need the flexibility .. if we discover some need for that, you know we can continue that pattern rowStyle, rowAttributes, rowWhatever
Quick note - in terms of considering our future move to css-in-js, I believe emotion allows passing in class names via a render prop, so I think you will still be able to use emotion and the class paradigm with this API. LMK if that sounds incorrect to you.
in terms of re-rendering, the most effective way to prevent re-renderings would be to target a row using Emotion , so just adding something like this:
I guess in terms of EuiDataGrid in Discover I will follow this approach, since it's already possible.
Thanks @kertal! Since no one else has expressed a need for more row customization other than CSS classNames, I'll move ahead with opening a PR with my existing logic for the gridStyle.rowClasses API.
Activity
github-actions commentedon Jun 21, 2021
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
snide commentedon Jun 21, 2021
Still valid. Added a skip check.
claudiopro commentedon Nov 22, 2021
Hi @snide, this enhancement would be a boon for Observability (and Discover I guess) to easily show row selection for the document/alert flyout. Would you have an ETA for this?
elizabetdev commentedon Nov 22, 2021
CC @constancecchen / @chandlerprall
snide commentedon Nov 22, 2021
Now that data grid uses an actual wrapper row, my guess is this should be much easier to add now. I'll leave it to @constancecchen for feedback.
cee-chen commentedon Nov 22, 2021
See this conversation also:
#5285 (comment)
claudiopro commentedon Nov 22, 2021
Super! Thank you all @snide @constancecchen @miukimiu 😃
cee-chen commentedon Jan 18, 2022
Quick update to this: #5515 incidentally adds the ability to quickly target all cells in a row with the following data attribute(s):
Note that this is primarily a vanilla JS workaround for grabbing cells by row that may help folks in the interim. It doesn't provide a React first-party API/prop for rendering specific rows and does not close out/resolve this issue. It also does not resolve the background image issue in the issue description.
On that front: while we implemented wrapping row DOM nodes in #5285, the DOM nodes primarily are there for accessibility and don't actually function as wrappers (they render with 0 height and have no actual visible DOM rendering). This is because react-window virtualization library absolutely positions all its cells - updating our added row nodes to have matching positions, height, and width would be a moderate lift. It's doable, but it's not a trivial effort unfortunately and is something that would need to be scoped out/put on the roadmap.
kertal commentedon Jan 19, 2022
Could emotion be used to highlight a row? could we as consumers assign custom ids to rows and then use emotion to make it pretty (or) ugly?
cee-chen commentedon Jan 19, 2022
You could do that now currently with CSS and data-attr targets, I don't think emotion would significantly change that lift.
Unfortunately, one of the specific requests for rows is that styling every cell in a row doesn't work for users who want a repeating background image to not break between cells, e.g.
cee-chen commentedon Jan 24, 2022
Me: This is a non-trivial effort
Also me: I'm bored on a Thursday afternoon, let's see if I can solve the row issue
Good news @kertal @claudiopro @machadoum - the PR #5555 gets our row DOM working, and from there on it's much easier to implement an API for the desired functionality. Example screencap (the CSS being applied is the
.euiMarkclass):The area where I could use your help/feedback is the API that consumers use to pass custom classes/styling to specific rows. My proposal is adding an API to the current
gridStyleprop that looks like this:I tried to keep the data structure intentionally similar to
rowHeightsOptions. However, my question for you all is whether this is flexible enough for the use case you are looking for or if you need more than this. Do you need the ability to pass any kind of prop (e.g. data attributes, inlinestyles, etc.) to rows? Or is just CSS classes sufficient for styling/appearances?Quick note - in terms of considering our future move to css-in-js, I believe emotion allows passing in class names via a render prop, so I think you will still be able to use emotion and the class paradigm with this API. LMK if that sounds incorrect to you.
kertal commentedon Mar 2, 2022
@constancecchen will follow up here, looking good 👍
kertal commentedon Mar 4, 2022
I scheduled some "boredom" to follow up on EUI issues :)
Looking good 👍
Also looking good 👍
For me CSS classes work fine, I wouldn't need the flexibility .. if we discover some need for that, you know we can continue that pattern
rowStyle,rowAttributes,rowWhateverin terms of re-rendering, the most effective way to prevent re-renderings would be to target a row using Emotion , so just adding something like this:

I guess in terms of EuiDataGrid in Discover I will follow this approach, since it's already possible.cee-chen commentedon Mar 14, 2022
Thanks @kertal! Since no one else has expressed a need for more row customization other than CSS classNames, I'll move ahead with opening a PR with my existing logic for the
gridStyle.rowClassesAPI.