Question about Multiple Filter Example

Question about Multiple Filter Example

ikhvjsikhvjs Posts: 9Questions: 3Answers: 0

I follow the example here https://datatables.net/examples/api/multi_filter.html

I can repeat this case.

However, I have question about this example.

The original code:

var table = $("#example").DataTable({
  initComplete: function () {
    // Apply the search
    this.api()
      .columns()
      .every(function () {
        var that = this;

        $("input", this.footer()).on("keyup change clear", function () {
          if (that.search() !== this.value) {
            that.search(this.value).draw();
          }
        });
      });
  },
});

I replace this.footer() to below but it doesn't work.

var table = $("#example").DataTable({
  initComplete: function () {
    // Apply the search
    this.api()
      .columns()
      .every(function () {
        var that = this;
        const footer = $(this).closest("table").find("tfoot");
        $("input", footer).on("keyup change clear", function () {
          if (that.search() !== this.value) {
            that.search(this.value).draw();
          }
        });
      });
  },
});

May I know why the codes I change doesn't work at all? Thanks.

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.