Searchable columns but remove from certain columns
Searchable columns but remove from certain columns

I love the search column feature. One issue I have though is what if I want to remove that function from col 0,3,9,10? How would I do that with the below script?
<script type="text/javascript" class="init">
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#rq tfoot td').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
$(document).ready(function() {
$('#rq').DataTable( {
scrollY: 2000,
scrollX: true,
scrollCollapse: true,
fixedColumns: true,
"dom": '<"toolbar">frtip',
"order": [[ 3, 'desc' ], [ 2, 'asc' ]],
lengthChange: true,
pageLength: 25,
dom: '<"top"i>rt<"bottom"flp><"clear">',
dom: 'Bfrtip',
pagingType: "full_numbers",
"language": {
"emptyTable": "<b><h3>Select a date range from above</h3></b>"
},
buttons: [
{ extend: 'csvHtml5',
footer: true,
text: 'Export',
filename: function(){
var d = new Date();
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
var n = d.getTime();
var now = new Date();
var months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
var formattedDate = now.getFullYear() + months[now.getMonth()] + now.getDate();
return formattedDate + '_VZW_Activations_Discrep_RQ'}
},
],
initComplete: function () {
// Apply the search
this.api().columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
}
});
} );
} );
</script>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Picture for illustration purposes
The
columns()
API can take differentcolumn-selector
options you can use. You can pass an array with column indexes. You can add a class to the columns you want searchable and pass that.Kevin
Im sorry, in my image i meant to say i need to remove that search box from the column. Not the whole column.
In the above line use
column-selector
as I described above to loop through only the desired columns.Kevin