select inputs 2 major problems
select inputs 2 major problems
muscaiu
Posts: 6Questions: 4Answers: 0
I'm using this code to add select inputs to the columns.
This comes with 2 major problems:
- Clicking the select inputs also sorts the column, that i don't want.
- Any export (excel, pdf, etc) will add extra weird data (row data) that i don't want.
How can i solve these problems?
Thank you.
var table = $('#myTable').DataTable({
dom: 'lfBrtip',
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 discussion has been closed.