Cannot read property 'searchLocalDataBy' of undefined


Topic: Cannot read property 'searchLocalDataBy' of undefined

AlexMart free asked 2 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 2 years ago

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


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Opened

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