Javascript 数据表子行
我在尝试重新创造 我的名字是 前端JavascriptJavascript 数据表子行,javascript,jquery,datatable,Javascript,Jquery,Datatable,我在尝试重新创造 我的名字是 前端Javascript $(document).ready(function() { $('#example').DataTable({ responsive: { details: { type: 'column', target: 'tr' } }, columnDefs: [{ className: 'control', orderable: fals
$(document).ready(function() {
$('#example').DataTable({
responsive: {
details: {
type: 'column',
target: 'tr'
}
},
columnDefs: [{
className: 'control',
orderable: false,
targets: 0
}],
order: [1, 'asc']
});
});
HTML
测试
测试
测试
测试
测试
1.
2.
3.
4.
5.
由于未知原因,“详细信息”行不会出现(最左侧列上的+/-符号也不会出现)
我做错了什么?您有两个问题:
@RacilHilan我提供的示例(官方文档)也没有显式地设置详细信息行。它只使用了最后一个TDP,为什么不开始复制整个演示,确保它正常工作,然后开始修改它呢?您缺少一些CSS和JavaScript引用(响应的引用)。加上它们,你就能让它工作了。
<table id="example" class="display nowrap" width="100%">
<thead>
<tr>
<th></th>
<th>test</th>
<th>test</th>
<th>test</th>
<th>test</th>
<th>test</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</tbody>
</table>
Look at the used external resources to see the correct libraries to import.