The functionality for select options for all the columns as mentioned on the website of data tables is mentioned below. How do i make it filter the table data on the drop down values of the first column only and also place the select drop down somewhere else rather than the usual header section.see link for example
initComplete: function () {
var api = this.api();
api.column().indexes().flatten().each( function (i) {
var column = api.column(i);
var select = $('<select><option value=""></option></select>').appendTo('$selectTriggerFilter').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>' )
} );
} );
}
I am using the following code . As soon as i remove the dom options the select options appear but not without dom.
$(document).ready(function() {
$('#tableTrigger').DataTable({
"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
searching: false,
"scrollY": "200px",
"dom": 'frtipS',
"deferRender": true,
initComplete: function ()
{
var api = this.api();
api.columns().indexes().flatten().each( function ( i )
{
if(i == 0){ //Create just one SelectBox
var select = $('<select class='+i+'><option value=""></option></select>')
.appendTo( '#selectTriggerFilter')
.on( 'change', function () {
var val = $(this).val();
column( i ).search( val ? '^'+$(this).val()+'$' : val, true, false ).draw();
});
column( i ).data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' );
} );
}
else return;
});
}
});
});