Induvidual search for every column not working, why not?

Induvidual search for every column not working, why not?

leocloleoclo Posts: 3Questions: 1Answers: 0

On my code below I am trying to apply a search to every column in the header, I am pretty sure the only thing not working is the that.search(this.value) since every time I write on the input boxes of every column the column that i just finished writing on is ordered on 'asc', so .order('asc') its working. Could anybody help me figure out why isn't .search(this.value) isn't working?

    var arrayColsIxs = [];
    // Setup - add a text input to each header cell
    $('#datatable thead tr:eq(1) th').each(function (index) {
        // var title = $(this).text();
        arrayColsIxs[index] = index;
        if (index > 0) {
            $(this).html('<input type="text" id="' + index + '" placeholder="Pesquisar..." />');
        }
    });

    var tableInstance = $('#datatable').DataTable({
        "sDom": 'l<"#toolbar">Bfrtip',
        'order': [[1, 'asc']],
        "scrollX": true,
        "bSortCellsTop": true,
        "searching": false,
        "buttons": [
            'pdf', 'csv', 'excel'
        ],
        'columnDefs': [{
            'targets': arrayColsIxs,
            'searchable': true,
        }],
    });
    tableInstance.columns().every(function (colIdx) {
        var that = tableInstance.columns(colIdx - 1);
        var id = colIdx - 1;
        $(document).on('keyup change', 'input#' + id, function () {
            // alert(id);
            if (that.search() !== this.value) {
                that
                    // .order('asc')
                    .search(this.value)
                    .draw();
            }
        });
    });

Answers

  • leocloleoclo Posts: 3Questions: 1Answers: 0

    got it! Just removing searching false!!!

This discussion has been closed.