Cannot read property 'searchLocalDataBy' of undefi


Topic: Cannot read property 'searchLocalDataBy' of undefined

AlexMart asked 4 years ago

Hello, I have literally followed the example tutorial and it indicates that this function is not defined.

ERROR TypeError: Cannot read property 'setDataSource' of undefined

  @ViewChild(MdbTableDirective, { static: true }) mdbTable: MdbTableDirective;
  elements: any = [];
  elementsCopy: any = [];
  searchText = "";
  previous: string;

    constructor(public ticketsService: TicketsService) {}
      @HostListener("input") oninput() {
        if (!this.alreadyGetterTickets) {
          this.searchItems();
        }
      }

  ngOnInit() {
    this.ticketsService.getTickets().subscribe((res) => {
      const response = res;
      this.elements = response["message"];
      this.elementsCopy = response["message"];
      this.previous = this.elementsCopy;

      setTimeout(() => {
        this.mdbTable.setDataSource(this.elements);
        this.previous = this.mdbTable.getDataSource();
        this.alreadyGetterTickets = false;
      }, 500);
    });
  }

Arkadiusz Idzikowski staff commented 4 years ago

Please provide full HTML/TS code of the table so we can reproduce this problem on our end.


AgileTuan pro commented 2 years ago

Me too

ERROR TypeError: Cannot read property 'setDataSource' of undefined


Arkadiusz Idzikowski staff commented 2 years ago

Which Angular and MDB Angular versions do you use? Could you provide some more information about the table HTML code?

Did you try to use the table method inside ngAfterViewInit hook instead of ngOnInit?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 9.3.1
  • Device: Desktop PC
  • Browser: Edge
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No