Angular Datatables: Unable to do individual column search on multiple DataTables. Have two tables and have to implement individual column search for both the tables. First table we can do column search without any issues, but second table we are unable to do column search. Tried with below code,
Code:
ngAfterViewInit(): void {
this.datatableElementList.forEach(datatableElement=>{
this.dtTrigger1.subscribe(() => {
this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.columns().every(function () {
const that = this;
$("input", this.footer()).on("keyup change", function () {
if (that.search() !== this["value"]) {
that.search(this["value"]).draw();
}
});
});
});
});
this.dtTrigger2.subscribe(() => {
this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.columns().every(function () {
const that = this;
$("input", this.footer()).on("keyup change", function () {
if (that.search() !== this["value"]) {
that.search(this["value"]).draw();
}
});
});
});
});
});
}
Stackblitz
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…