[英]Dynamically add headers in table datatable
Is it possible to work with 2 rows in THEAD
with dataTables? 可以在THEAD
使用dataTables处理2行吗?
<table>
<thead>
## row 1
## row 2
</thead>
<tbody></tbody>
</table>
In row 1 I need 2 single columns and one column with colspan="3"
: 在第1行中,我需要2个单列和1个具有colspan="3"
:
<tr>
<th></th>
<th></th>
<th colspan="3"></th>
</tr>
And in row 2 I need 5 columns: 在第2行中,我需要5列:
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
But I have a case where I don't need 5 columns, but only 3. 但是我有一种情况,我不需要5列,而只需要3列。
Can this be generated dynamically? 可以动态生成吗?
UPDATE : I tried: http://datatables.net/release-datatables/examples/basic_init/complex_header.html 更新 :我尝试过: http : //datatables.net/release-datatables/examples/basic_init/complex_header.html
But there's no good example how it's generated. 但是没有很好的例子说明它是如何产生的。
If you look at the source code of the example link you posted , it seems quite clear: 如果您查看发布的示例链接的源代码,则看起来很清楚:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th rowspan="2">Rendering engine</th>
<th rowspan="2">Browser</th>
<th colspan="3">Details</th>
</tr>
<tr>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tfoot>
<tr>
<th rowspan="2">Rendering engine</th>
<th rowspan="2">Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
<tr>
<th colspan="3">Details</th>
</tr>
</tfoot>
(Code lifted from link above) (代码从上面的链接中删除)
A word on viewing source code: In Firefox you can press ctrl + u to view the page source code. 关于查看源代码的一句话:在Firefox中,您可以按ctrl + u查看页面源代码。 Even if there is heavy jQuery action on the page, the source code in that window will always be the original one without DOM modifications. 即使页面上有大量jQuery动作,该窗口中的源代码也始终是原始代码,无需进行DOM修改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.