使用客户端HTML表排序对行进行分组

Ala*_*orm 6 html javascript jquery

是否有任何现有的表排序库,或者有没有办法配置tablesorter,以排序每两行?另外,是否有更好的方法来表达我的表格,以便标准行排序可行.

我有一个看起来像这样的html表

<table>
    <thead>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Some Data: 1</td>
            <td>Some More Data:1 </td>
        </tr>
        <tr>
            <td colspan="2">Some text about the above data that puts it in context and visually spans under both of the cells above so as not to create a weird looking table</td>
        </tr>

        <tr>
            <td>Some Data: 2</td>
            <td>Some More Data: 2</td>
        </tr>
        <tr>
            <td colspan="2">Some text about the above data 2 set that puts it in context and visually spans under both of the cells above so as not to create a weird looking table</td>
        </tr>           

    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种方法来对表进行排序,使得表按数据行排序,但是带有colspan的行与其数据一起传播并且不单独排序.

pba*_*ney 2

有人为 tablesorter 开发了这个功能。查看此页面:

http://blog.pengoworks.com/index.cfm/2008/3/28/Finished-jQuery-Tablesorter-mod-for-Collapsible-Table-Rows

您需要做的就是为次要行提供“expand-child”类(这是可配置的)。

正是您所需要的。