filamentgroup / tablesaw

A group of plugins for responsive tables.
MIT License
5.48k stars 434 forks source link

Is it Possible for Sortable Tables to Sort on Hidden Data? #248

Closed stevenyix closed 7 years ago

stevenyix commented 8 years ago

Great work on these components. Very cool.

Can Sortable Tables sort data that is hidden? For example, I'm building a weather website where I want to sort on a numeric value of % chance of precipitation, but all I want to show the user is a weather icon (e.g. - partly sunny, cloudy, rain, etc.)

Thanks!

zachleat commented 7 years ago

Good question!

There is always the option to do a custom sort function with data attributes. See the very bottom of this portion of the readme (there is a collapsible there you’ll need to expand): https://github.com/filamentgroup/tablesaw#sortable

BUT, I think the better option would be to use an Accessibility Hiding technique for the text. This way, it won’t be visible to sighted users, but will still have a meaningful value for both screen readers and the tablesaw sort.

It would be something like visually-hidden here: http://a11yproject.com/posts/how-to-hide-content/

Here is one from the HTML Boilerplate: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css#L119

As long as it shows up when you call jQuery’s .text() method on the cell, it’ll work with tablesaw.