我的html表包含两个标题行,如下所示。我想固定四分之一列,我在jquery datatable插件中尝试了一个示例,但是随着我的扩展它不起作用。该表已转换为数据表,但第一列未固定
我尝试过的示例 https://datatables.net/extensions/fixedcolumns/examples/initialisation/left_right_columns.html
HTML
<table id="example" class="table table-stripped">
<thead>
<tr>
<th rowspan="2">Quarter</th>
<th colspan="10">ICT Sector</th>
<th colspan="10">Shipping</th>
</tr>
<tr>
<th>WSO2</th>
<th>IFS</th>
<th>Company A</th>
<th>Company B</th>
<th>Company C</th>
<th>Company D</th>
<th>Company E</th>
<th>Company F</th>
<th>Company G</th>
<th>Company H</th>
<th>PSA</th>
<th>Mercantile Shipping</th>
<th>Company A</th>
<th>Company B</th>
<th>Company C</th>
<th>Company D</th>
<th>Company E</th>
<th>Company F</th>
<th>Company G</th>
<th>Company H</th>
</tr>
</thead>
<tbody>
<tr>
<td>Quater 1</td>
<td>100</td>
<td>700</td>
<td>800</td>
<td>900</td>
<td>1100</td>
<td>2200</td>
<td>7821</td>
<td>8862</td>
<td>6231</td>
<td>5891</td>
<td>100</td>
<td>700</td>
<td>800</td>
<td>900</td>
<td>1100</td>
<td>2200</td>
<td>7821</td>
<td>8862</td>
<td>6231</td>
<td>5891</td>
</tr>
<tr>
<td>Quater 1</td>
<td>100</td>
<td>700</td>
<td>800</td>
<td>900</td>
<td>1100</td>
<td>2200</td>
<td>7821</td>
<td>8862</td>
<td>6231</td>
<td>5891</td>
<td>100</td>
<td>700</td>
<td>800</td>
<td>900</td>
<td>1100</td>
<td>2200</td>
<td>7821</td>
<td>8862</td>
<td>6231</td>
<td>5891</td>
</tr>
</tbody>
</table>
JavaScript
$(document).ready(function() {
var table = $('#example').DataTable( {
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false,
fixedColumns: {
leftColumns: 1
}
} );
} );