我正在使用jQuery數據表插件。如何使用JQuery數據表插件隱藏表中的列?
我試圖用columnDef
隱藏一些列,但它們仍然出現。如何使用columnDef
來隱藏某些列?
這裏是我的代碼:
你有語法錯誤在你的代碼<div id="LabResultDataTableView">
<table id="TimelineTableTester" class="table table-striped table-bordered">
<thead class="td-datatable">
@foreach (var data in Model.ColumnNames)
{
<th style="background-color: inherit !important;">@data</th>}
}
</thead>
<tbody>
@for (int i = 0; i < Model.columnValuesRowWise.Count; i++)
{
<tr>
@foreach (var col in Model.columnValuesRowWise[i])
{
<td>@col</td>
}
</tr>
}
</tbody>
</table>
</div>
$(document).ready(function() {
debugger;
ProceduresAndOfficeVisitsDataView = $('#TimelineTableTester').DataTable({
"bProcessing": true,
"bDeferRender": true,
"scrollX": true,
"bSort": false,
"stateSave": true,
"bAutoWidth": true,
"columnDefs": [
{
"targets": [0],
"visible": false,
},
{
"targets": [11],
"visible": false,
},
{
"targets": [12],
"visible": false,
}]
});
});
更加明確的措辭。 – Prune
我的答案是否解決了您的問題? –
感謝您的仁慈幫助 – rajiv