Fixed column with individual column searching (select inputs)

Fixed column with individual column searching (select inputs)

juliencitrusjuliencitrus Posts: 2Questions: 0Answers: 0

Hi,

Fixed column doesn't work with individual column searching (select inputs). If i select a value on the select of the fixed column the result is not good.

Have you got an idea ?

This is my JS

var table = $('#example').DataTable({

    dom: 'lfrtip',
    scrollX:        true,
    scrollCollapse: true,
    lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
    autoWidth: true,
    fixedColumns: true,
    initComplete: function () {
        this.api().columns([0, 2, 9]).every( function () {
            var column = this;
            var select = $('<select><option value="">Rechercher...</option></select>')
                .appendTo( $(column.header()).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>' )
            } );

        } );

    },
});

THX,

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • juliencitrusjuliencitrus Posts: 2Questions: 0Answers: 0

    Hi,

    This is the link for the test case : http://live.datatables.net/vobofugi/1/edit?html,js,output

    We can see when we change the select of the fixed column, this column doesn't refresh.

    Thx,

    Julien.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    There are a couple of things you need to consider.

    The first, is that the FixedColumn extension places an overlay over the table, which needs to be considered. This example from this thread discusses/demonstrates that.

    The other point is that you've got the elements in the single row header, so you either need to consider orderCellsTop (example here) with an additional row, or, do something like this example from this thread,

    Colin

This discussion has been closed.