Reputation: 7022
My HTML is like below.
<table id="address_datatable" class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>Company Name</th>
<th>Contact Name</th>
<th>Email Address</th>
<th>Phone Number</th>
<th>Action</th>
</tr>
</thead>
<tbody>
My jQuery code is like below
$(document).ready(function() {
$('#address_datatable').DataTable({
"columnDefs": [ {
"targets": [ 0, 2 ],
"orderable": false
} ]
});
});
2 is working in "targets"
but 0 is not working.
I tried below example also. It is not working
$('#example').dataTable( {
"columnDefs": [ {
"targets": 'nosort',
"orderable": false
} ]
} );
Why it is happening like this ?
Upvotes: 0
Views: 202
Reputation: 45
Please add more details to your question.. Are you using ajax data source or simple static table data?
If ajax do the following.
ajax:{
type:'post', // whatever method
url:"your url"
},
"columns": [
//Specify your columns here
],
columnDefs:[
//Column definitions here
]
} );
Upvotes: 1
Reputation: 56
try this way
in HTML
<table id="address_datatable" class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>Company Name</th>
<th>Contact Name</th>
<th>Email Address</th>
<th>Phone Number</th>
<th class="nosort">Action</th>
</tr>
</thead>
<tbody>
in JS
$('#address_datatable').dataTable( {
"columnDefs": [ {
"targets": 'nosort',
"orderable": false
} ]
} );
Upvotes: 1