Method Column() not works for DataTable with javascript source ,another way to hide and show coumns?
Method Column() not works for DataTable with javascript source ,another way to hide and show coumns?
Methods like Column("0") , Column("1").visible(false) ...
work with DataTable with data html source like that
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
</tbody>
</table>
table = $('#example').DataTable();
var col = table.column("0").visible(false);
But it does not works and launch an error with DataTable with javascript source like that:
table = $('#example').dataTable({
"data": source,
"columns": columns,
"columnDefs": defs
});
table = $('#example').DataTable();
var col = table.column("0").visible(false);
Is exist anotherway to hide or show columns?
This question has an accepted answers - jump to answer
Answers
I finally found, we can do like that:
table.fnSetColumnVis(3, false);
I don't understand why it is working with that function and no wwith column()but it works!
It doesn't work with that because you are using
dataTable
rather thanDataTable
. See the second top FAQ :-)Allan
thank!!!