noocyte
noocyte

Reputation: 2522

Using tablesorter to sort one column based on the values of another?

I have a table that looks a little like this:

    ID    Paragraph  Title
    1     §1-1       This is the first
    2     §2-1       This is the second
...
    12    §10-1      This is the twelfth

The 'ID' column is hidden, the other two are visible. I've managed to get JQuery Tablesorter to work on sorting Paragraph and Title columns, however I would like to use the ID values when sorting the Paragraph column. Simply because the sorting is incorrect when using the Paragraph column as one can easily see.

Is it possible to somehow make tablesorter use the ID column/values when sorting the Paragraph column?

Upvotes: 4

Views: 2862

Answers (1)

Mottie
Mottie

Reputation: 86453

I think the easiest solution would be to just add a hidden span in the paragraph column with the ID inside and a space after to separate it from the text (<span class="hidden"># </span>) (demo)

<tr>
  <td>1</td>
  <td><span class="hidden">1 </span>Paragraph of text</td>
</tr>

Upvotes: 3

Related Questions