我正在使用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