Click here to Skip to main content
15,900,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,i am using a server side datatable where i fetch data from my sqldaabase. but my column search is not working.

What I have tried:

<script>
    $(document).ready(function() {
        $('#order_data thead th').each(function() {
            var title = $(this).text();
            $(this).html(title + ' <input type="text" class="col-search-input" placeholder="Search ' + title + '" />');
        });

        var table = $('#order_data').DataTable({
            "processing" : true,
    "serverSide" : true,
    "order" : [],
    "ajax" : {
     url:"fetch.php",
     type:"POST"
    },
    drawCallback:function(settings)
    {
     $('#total_order').html(settings.json.total);

    },
        });

        table.columns().every(function() {
            var table = this;
            $('input', this.header()).on('keyup change', function() {
                if (table.search() !== this.value) {
                    table.search(this.value).draw();
                }
            });
        });
    });
</script>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900