select inputs 2 major problems

select inputs 2 major problems

muscaiumuscaiu Posts: 6Questions: 4Answers: 0
edited May 2016 in Free community support

I'm using this code to add select inputs to the columns.
This comes with 2 major problems:

  1. Clicking the select inputs also sorts the column, that i don't want.
  2. 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.