0
我是jquery和datatable的新手,但很快学习。隐藏数据表中的列if if
我想根据我将测试的变量的值隐藏特定的列if。但我不知道在哪里说如果和代码来隐藏列。
HTML:
<table id="table_id" class="table table-striped table-bordered table hover" width="100%" cellspacing="0" >
<thead>
<tr>
<th>Have</th>
<th>A</th>
<th>Good</th>
<th>Day</th>
</tr>
</thead>
的Jquery:
$(document).ready(function() {
$('#table_id').DataTable({
"processing": true,
"order": [[ 3, "desc" ]],
"ajax": {
"url": "somewhere.php",
"type": "POST"
},
"columns": [
{ "data": "Have" },
{ "data": "A" },
{ "data": "Good" },
{ "data": "Day" }
]
});
});
伪的,如果
if($_POST('something') =="hey"){
hide column 1 and 2;}
这应该被标记'[jquery-datatables]',但由于某种原因,它不让我通过编辑来改变它。 –
https://datatables.net/reference/api/column().visible() –
我试图添加这个标签,但不能。是的,我看到了API,但它看起来像代码需要在某个特定的地方,因为当我尝试它没有工作。 – Romain