Angular Datatables: ERROR Error: Cannot read property 'then' of undefined
Angular Datatables: ERROR Error: Cannot read property 'then' of undefined
尝试列搜索时,我收到“错误错误:无法读取未定义的 属性 'then'”。你能给我建议问题吗...
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();
}
});
});
});
您应该在 ngAfterviewInit 中重新渲染而不是使用 Demo
rerender(){
this.datatableElementList.forEach(datatableElement=>{
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();
}
});
});
});
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();
}
});
});
});
});
}
ngAfterViewInit(): void {
this.dtTrigger1.next();
this.dtTrigger2.next();
}
尝试列搜索时,我收到“错误错误:无法读取未定义的 属性 'then'”。你能给我建议问题吗...
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();
}
});
});
});
您应该在 ngAfterviewInit 中重新渲染而不是使用 Demo
rerender(){
this.datatableElementList.forEach(datatableElement=>{
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();
}
});
});
});
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();
}
});
});
});
});
}
ngAfterViewInit(): void {
this.dtTrigger1.next();
this.dtTrigger2.next();
}