Reputation: 55
if (typeof dataTable_leads == 'undefined') {
dataTable_leads = $('#GlTable').dataTable({
"bDestroy": true,
"bRetrieve": true,
"bProcessing": true,
"bDeferRender": true,
"aaData": dataset,
"bPaginate": false,
"aaSorting": [
[5, 'asc']
], //desc
"columnDefs": [
{ "visible": false, "targets": [0] }
],
My datatable is working properly. But am trying to hide first column in my table. But its not working.Am using ColumnDefs datatable property here but its not working. Please help me
Upvotes: 1
Views: 4314
Reputation: 1529
Hiding a column requires somethign like this (API Doc):
$(document).ready(function() {
$('#example').DataTable( {
"columnDefs": [
{
"targets": [ 2 ],
"visible": false,
"searchable": false
},
{
"targets": [ 3 ],
"visible": false
}
]
} );
} );
Hence your columnDefs should be strictly as follows:
"columnDefs": [
{
"targets": [ 2 ],
"visible": false,
"searchable": false
},
{
"targets": [ 3 ],
"visible": false
}
]
To see the exact error that's happening, open up the developer tools in your browser and see the error log to see any errors that is happening.
Upvotes: 0
Reputation: 1712
You can hide columns by this command:
fnSetColumnVis( 1, false );
Where first parameter is index of column and second parameter is visibility.
Via: http://www.datatables.net/api - function fnSetColumnVis
It may help you.
Upvotes: 0
Reputation: 1231
i think this will help you. add this line after your datatable is load.
table.column( 0 ).visible( false );
Upvotes: 1