Re: [whatwg] Sortable Tables

On Wed, Nov 7, 2012 at 6:55 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 11/6/12 11:39 AM, Ojan Vafai wrote:
>
>> This is a use-case that I absolutely think it makes sense to address.
>>
>
> Agreed.  Not that I can commit to implementing, necessarily, but I do
> think this is a common want.
>
>
Great to hear browser interest! It's something I've had to implement for
basically all Web apps I've been involved with developing, so am really
keen to get browsers to take this over.

Not quite new, but a good requirements analysis can be had from the list of
JS solutions here:
http://tympanus.net/codrops/2009/10/03/33-javascript-solutions-for-sorting-tables/

I our apps, we'd typically not associate sortable to the table, but to a
column header.
Typical classes/attributes we'd add to a table header cell:
* sortable class: boolean
* data-direction: ascending/descending
* data-type: date, number, text etc which determines the comparison
function used in sort
* data-sort-prio: numeric indicating sorting priority

Also, a sortable table's header needed some indication of the sortability,
so some default CSS like this:
    th.sortable {
      &:after { content: " ▲▼"}
      &.current{
        &[data-direction="asc"]:after { content: " ▼"}
        &[data-direction="desc"]:after { content: " ▲"}
      }
    }

HTH...

Cheers,
Silvia.

Received on Tuesday, 6 November 2012 22:19:29 UTC