1

While trying the column search, I'm getting "ERROR Error: Cannot read property 'then' of undefined". Could you please suggest me the issue...

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

enter image description here

1
  • Please check this link. It might be helpful. Commented Feb 18, 2021 at 7:56

1 Answer 1

1

You should rerender rather than using in 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();
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.