elm-ui icon indicating copy to clipboard operation
elm-ui copied to clipboard

Attributes for table rows

Open Herteby opened this issue 6 years ago • 7 comments

It's pretty common to have a table of items that the user can click / select - which means having styles / click handlers on the rows. You can sort of emulate this by putting identical els in each cell with styles and click handlers on them. However, mouseOver decorators don't work as you would want, since they will only apply to the cell rather than the row.

Suggestion:

Element.tableWithRowAttributes []
    { data = [...]
    , columns = [...]
    , rowAttributes = \item -> [ mouseOver [ Background.color lightGrey ]  etc...]
    }

As a side note, Element.indexedTable seems a little redundant, as you could just use List.indexedMap Tuple.pair on the data, and when you use Dict.toList you already get it "for free"

Herteby avatar Jan 24 '19 14:01 Herteby

+1 to this feature, I really think this is very useful, I don't know what @mdgriffith thinks about this, but I could give a shot ( I haven't started to do because I read the Contributing.md :) )

jouderianjr avatar Jun 21 '19 10:06 jouderianjr

What's the current state of this issue? @mdgriffith is the present feature request consistent with (1) the architecture and (2) technically feasible?

benjaminweb avatar Mar 31 '20 11:03 benjaminweb

I'm also interested in this feature and I would like to hear about any progress. If you look at any popular css framework (bootstrap, bulma,..) the basic thing they offer is highlighting the current row for example.

nilehmann avatar Apr 20 '20 02:04 nilehmann

Also looking for a solution to this. I would love to have alternating row colors along with a click event for the entire row rather than one for each individual cell.

Markloev avatar May 15 '20 01:05 Markloev

I'm interested in this as well. I maintain a lot of reporting tables for a personal project and need to be able to format/work with whole rows, not just cells.

vurguuz avatar Jun 01 '20 10:06 vurguuz

I'm trying to add separator lines to tables, I'd also love to have this feature!

raffomania avatar Oct 10 '21 18:10 raffomania

I came here looking for alternating row colors and ultimately found this little CSS trick that solves my problem:

tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}

kimtore avatar Sep 13 '22 12:09 kimtore