Server-side search column same value in all input text

Server-side search column same value in all input text

callejascallejas Posts: 3Questions: 1Answers: 0

hi,

i'm using search with individual column in server side (ASP.NET MVC ), however all the input text for each column are of the same value .

javascript:

$('#Pagadores tfoot th').each(function () {
var title = $(this).text();
$(this).html('<input type="text" placeholder="Pesquisar..." class="form-control ms-clear"/>');
});

I have 3 input text in DataTable and all of them return de same value entered.

Can someone help me?

Sorry, my english is no good.

Answers

  • callejascallejas Posts: 3Questions: 1Answers: 0

    this solved.

    i changed the code:

    table.columns().every(function () {

            $('tfoot input', this.footer()).on('keyup change', function () {
                that
                    .search(this.value)
                    .draw();
            });
        });
    

    by:

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

                api.columns().every(function() {
                    var that = this;
    
                    $('input', this.footer()).on('keyup change', function() {
                        if (that.search() !== this.value) {
                            that
                              .search(this.value)
                              .draw();
                        }
                    });
                });
            },
    

    in the datatable parameters.

This discussion has been closed.