1

我使用 datatable.bundle.js 使用了 jQuery Datatable。一切正常,但是当我keyup在单个列搜索输入上使用事件时,该事件会触发但column.search(this.value).draw();不起作用。

this.api().columns().every(function(index) {
  let column = this;
  $('#user-data input').on('keyup change', function() {
    //alert("changed");
    console.log("key is pressed");
    //column.search(this.value).draw()
    //console.log("inside");
    if (column.search() !== this.value) {
      column.search(this.value).table.draw();
    }

  });
}

我试过这个

this.api().columns().every(function(index) {
  let column = this;
  $('#user-data input').on('keyup change', function() {
    //alert("changed");
    console.log("key is pressed");
    //column.search(this.value).draw()
    //console.log("inside");
    if (column.search() !== this.value) {
      column.search(this.value).table.draw();
    }
  });
}

该事件正在运行,但绘图功能不起作用

4

1 回答 1

0

根据文档,您需要table从方法调用中删除。

column.search(this.value).draw();

代替

column.search(this.value).table.draw();
于 2019-02-06T13:44:33.747 回答