dataTable最新版(1.10.9)已经提供了colspan和rowspan的设置,参考:
http://www.datatables.net/examples/basic_init/complex_header.html
但是我发现这个设置在不使用ajax的情况下是正常的,使用ajax加载数据在某些情况下会有问题,比如要实现下面这种效果
也就是说如果表头分两行,列的数目和数据列数目还是相同的话,像第一个图,就没事,如果像上面这个图,表头只有一行,并且在某一列使用了colspan=2,使用ajax加载会报错。
最后没办法使用下面的方法来避免报错
<table id="menu_table" class="table table-bordered table-striped" width="100%">
<thead>
<tr>
<th class="index" rowspan="2">序号</th>
<th class="index" rowspan="2"><input id="allcheck" type="checkbox" /></th>
<th rowspan="2">菜单代码</th>
<th rowspan="2">菜单名称</th>
<th rowspan="2">链接地址</th>
<th rowspan="2">菜单状态</th>
<th rowspan="2">排序序号</th>
<th rowspan="2">上级菜单</th>
<th colspan="2" style="border-bottom:none">使用指南</th>
<th width="80px" rowspan="2">操作</th>
</tr>
<tr>
<th style="display:none">状态</th>
<th style="display:none">内容</th>
</tr>
</thead>
<tbody></tbody>
</table>
还是分两行,但是把第二行的内容隐藏掉。