individual column searching not working with scrollX = true

individual column searching not working with scrollX = true

alfred.angkasaalfred.angkasa Posts: 2Questions: 0Answers: 0

Hi, i have a problem regarding the individual searching with scrollX = true.

if i comment scrollX = true, the individualSearch is working.

` $(document).ready(function() {
// Setup - add a text input to each footer cell

        $('#dataTable thead tr:eq(1) th').each( function (i) {
            var title = $('#dataTable thead tr:eq(0) th').eq( $(this).index() ).text();
            $(this).html( '<input type="text" placeholder="Search '+title+'" data-index="'+i+'" />' );
        } );

        var dataTable = $('#dataTable').DataTable( {
            "processing": true,
            "scrollX": true,
            "fixedColumns" : true,
            "orderCellsTop" : true,
            "language": {
                "processing": "Hang on. Waiting for response..." //add a loading image,simply putting <img src="loader.gif" /> tag.
            },
            "serverSide": true,
            "ajax":{
                url :"server_processing.php", // json datasource
                type: "post",  // method  , by default get
                error: function(){  // error handling
                    $(".dataTable-error").html("");
                    $("#dataTable").append('<tbody class="dataTable-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                    $("#dataTable_processing").css("display","none");

                }

            },
            initComplete: function() {
                var api = this.api();

                // Apply the search
                api.columns().every(function(index) {
                    var that = this;

                    $('#dataTable thead tr:eq(1) th:eq(' + index + ') input', this.table().container() ).on( 'keyup change', function () {
                        alert("A");
                        if (that.search() !== this.value) 
                        {
                            that.column($(this).parent().index() + ':visible')
                            .search(this.value)
                            .draw();
                        }
                    } );


                });
            }
        } );
    } );`

any clue / help to solve this?

Replies

This discussion has been closed.