Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting tables with multilevel headers #26

Open
AlKult opened this issue Nov 6, 2019 · 1 comment
Open

Sorting tables with multilevel headers #26

AlKult opened this issue Nov 6, 2019 · 1 comment

Comments

@AlKult
Copy link

AlKult commented Nov 6, 2019

Hi,

When I have sortable enabled for a table like this one, the sorting works only for the top-level headers ("Mars" and "Venus")
image
Is there any way to make it sort by the second level ("Produced", "Sold")?

The code that I have been experimenting with would be

<table class="sortable">
  <col>
  <colgroup span="2"></colgroup>
  <colgroup span="2"></colgroup>
  <tr>
    <td rowspan="2"></td>
    <th colspan="2" scope="colgroup">Mars</th>
    <th colspan="2" scope="colgroup">Venus</th>
  </tr>
  <tr>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
  </tr>
  <tr>
    <th scope="row">Teddy Bears</th>
    <td>50,000</td>
    <td>30,000</td>
    <td>100,000</td>
    <td>80,000</td>
  </tr>
  <tr>
    <th scope="row">Board Games</th>
    <td>10,000</td>
    <td>5,000</td>
    <td>12,000</td>
    <td>9,000</td>
  </tr>
</table>

Best regards,
Albert.

@stuartlangridge
Copy link
Owner

Unfortunately, sorttable doesn't understand two-level headers at the moment. It would be possible to do so with some custom enhancements (drop me an email if that would be useful), and it's something I'd like to address in sorttable v3, but for the moment it's not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants