DataTable Individual column searching, I need only one select inputs
DataTable Individual column searching, I need only one select inputs
oioioi
Posts: 1Questions: 1Answers: 0
I have a table. Datatable column search is added to all fields. I just need select search for "Positions" fields . and I want text search support for above x mark(check image).
I am using it for the first time so, suggest a resource for this. thank you.
Image
My codes:
$(document).ready(function() {
$('#example').DataTable( {
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.21/i18n/Turkish.json"
},
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()) )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
columns
API takes an array of column indexes to select the columns. You can do something like this in line 10:this.api().columns( [1] ).every( function () {
Kevin