views:

165

answers:

1

Sorry for this title, I didn't know how to describe it better.

I have the following table:

<tr class="row-vm">
    <td>...</td>
    <td>...</td>
    ...
</tr>
<tr class="row-details">
    <td colspan="8">
        <div class="vmdetail-left">
        ...
        </div>
        <div class="vmdetail-right">
        ...
        </div>
    </td>
</tr>

Every second row contains detail data for the first row. By default, it is hidden with CSS, but I can slide it open with jQuery.

What I would like to achieve: Table sorting similar to this jQuery plugin: http://tablesorter.com/docs/

The problem: The plugin should "glue together" all pair rows, and move them together. The sorting should be done only with the data of the first row (.row-vm), while ignoring the content of the second row (.row-details).

Is there a jQuery plugin that supports this?

A: 

I know this doesn't answer your actual question about an alternate tablesorter, but I think you might find more success just rearranging the HTML, and using any regular tablesorter without the need for special requirements.

Maybe you could put the visible row information, and the "hidden" data in the same row, and just emulate the fact that they are in different rows?

i.e.:

<tr>
  <div class="row-vm">
    ... info goes here- this can be in the form of floated divs,
        a ul, another table, or whatever suits you best
  </div>
  <div class="row-details">
    ... this is hidden, but can be expanded
  </div>
</tr>

The less table elements you use, the better..

Jeriko
Hmm. I thought about something like this too, but according to the HTML specification, a `<tr>` can only contain `<td>`'s and `<th>`'s. As the data seems to be in a real tabular format, the use of a `<table>` is justified here. The peculiarity lies in the detail rows.
MvanGeest
Exactly. If it wouldn't be tabular data, I would have chosen DIVs. Multiple (8) floated DIVs are (unfortunately) no solution to this problem.
danilo
I _think_ the tablesorter plugin is going to require td's. On top of that, any solution that merges the master-detail is going to require at least a custom sorter be written.
Marc
Yes, the tablesorter plugin requires td's. The writing of custom sorters is no problem, but it won't help me as long as I can't combine two rows.
danilo
I guess I can't really see any other way- on one hand you're saying you can only have `<tr><td /><td /><td /></tr>`, but on the other you want non-linear data to be stored in a linear row.. Unless you store the row data in some kind of `data-foo="bar"` and then dynamically build/insert the row in jQuery on click? You could also delete before sorting, and if necessary re-build on the other side?
Jeriko
Hm, good idea with re-building. Could work. But I think in my case it's not worth the effort. I just wondered whether there are some sorting plugins that support double rows by themselves.
danilo
Would probably be quicker to implement than spend any more time finding such a specific plugin ;) Good luck!
Jeriko