Column filter(select/text) is not working for fixed columns. Rest all columns filtering are working.

Column filter(select/text) is not working for fixed columns. Rest all columns filtering are working.

vasanthkhvvasanthkhv Posts: 1Questions: 1Answers: 0
edited June 2017 in Free community support

initComplete: function () {

  this.api().columns().every( function () {

    var column = this;

    var columnIndex = this.index();

    switch ($(".filter th:eq("+columnIndex+")").attr('class')) {

        case 'select-filter': 
                                  var select = $('<select style="width:100%;"><option value=""></option></select>')

                                                .appendTo( $(".filter th:eq("+columnIndex+")").empty() )
                                                .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>' )
                                  });
                                  break;

            case 'text-filter': 
                                  $(".filter th:eq("+columnIndex+")").html( '<input type="text" size="5"/>' );

                                  $( 'input', $(".filter th:eq("+columnIndex+")") ).on( 'keyup change', function () {
                                    if ( column.search() !== this.value ) {
                                        column
                        .search( this.value )
                                            .draw();
                                     }
                                  });
                                  break;
      }
);

}

This discussion has been closed.