jennschiffer / timbles.js

a very simple jQuery plugin for tables, made by the person who literally did not invent tables
MIT License
38 stars 4 forks source link

Support for multi-row headers with subdivisions #5

Open edelooff opened 9 years ago

edelooff commented 9 years ago

Currently timbles works for single header-row tables only.

I'm currently looking at a table with a multi-row <thead> that I would like to be sortable and have it do "the right thing". With some use of colspan and rowspan, the header groups a number of columns under a shared prefix or context if you will. Something along the lines of:

|===============================================|
| Customer | Item | Date |      Delivery        |
|                        | Date | Cost | Status |
|-----------------------------------------------|

Sorting this will cause the second header row to be thrown around, in addition to being unsortable.

What I would like it to do is be sortable on any of the non-spanning columns ('Customer', 'Item', 'Date', 'Date', 'Cost' and 'Status'). Though explicitly marking the 'Delivery' span as nosort would be fine, there might be cases where sorting a span makes sense.

Is this use case in the scope of timbles and something you'd accept PRs for, or even have ideas toward to implementing?

jennschiffer commented 9 years ago

Yeah I implemented this for stats.nba.com when I worked there and was sorta on the fence with implementing it in timbles because my goal for this was to keep this plugin super simple and maybe create separate add-ons. I think nested headers would make a great add-on as opposed to "core" timbles feature. I already built such a thing and I think I'll revisit it after pr #4 if merged, since that would affect it. :santa:

edelooff commented 9 years ago

Sounds good. I think there's some room for improvement (making things easier) on how the headers (and the sortable body) are detected by making use of <thead> and <tbody> elements rather than taking the first row and then everything else as body. Though of course that depends on how much developer laziness is to be supported, and how various browsers deal with the lack of a <tbody>. I know Chrome creates one and I suspect Firefox does the same. What IE does I've (thankfully) no idea.

Two more things:

  1. This little plugin is awesome and solved a problem I'd been neglecting for some time, thanks!
  2. When you say you want to keep it "super simple", what's your metric for that? Lines of souce, code complexity, no. of features, or something else entirely?