Topic: Error when search for an item on table
JoaodaCruz asked 6 years ago
When I insert data in the input and click on the button to make a search give me an error ' Cannot read property 'toString' of null', i insert text or numbers and the error is the same. Someone have a ideia so i can solve that problem? Bellow i attach my code and the error.
Thanks for your time,
Html:
<div class="btn-group">
<input type="text" [(ngModel)]="searchText" placeholder="search" class="form-control" id="search" mdbInput>
</div>
<div class="btn-group">
<button class="btn btn-primary" (click)="searchItems()" ><i class="mdi mdi-15px mdi-magnify"></i></button>
</div>
TypeScript:
searchItems() {
const prev = this.tableService.getDataSource();
if (!this.searchText) {
this.tableService.setDataSource(this.previous);
this.elements = this.tableService.getDataSource();
}
if (this.searchText) {
this.elements = this.tableService.searchLocalDataBy(this.searchText);
this.tableService.setDataSource(prev);
}
}
Error:
ERROR TypeError: Cannot read property 'toString' of null
at angular-bootstrap-md.js:8414
at Array.some (<anonymous>)
at angular-bootstrap-md.js:8409
at Array.filter (<anonymous>)
at MdbTableService.push../node_modules/angular-bootstrap-md/fesm5/angular-bootstrap-md.js.MdbTableService.filterLocalDataBy (angular-bootstrap-md.js:8404)
at MdbTableService.push../node_modules/angular-bootstrap-md/fesm5/angular-bootstrap-md.js.MdbTableService.searchLocalDataBy (angular-bootstrap-md.js:8431)
at SimCardsComponent.push../src/app/shared/environment-dashboard/components/simcards/simcards.component.ts.SimCardsComponent.searchItems (simcards.component.ts:140)
at Object.handleEvent (simcards.component.html:26)
at handleEvent (core.js:19676)
at callWithDebugContext (core.js:20770)
Damian Gemza staff answered 6 years ago
Dear JoaodaCruz,
Could you please provide me with the full code of your table? The markup (html) and the logic (ts) parts of that component. Without it, I won't be able to debug your problem.
Best Regards,
Damian
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: 7.4.2
- Device: Laptop
- Browser: chrome
- OS: windows 10 64bit
- Provided sample code: No
- Provided link: No