Topic: datatable firing again
Aroquiassamy LA ROZE priority asked 9 hours ago
datatable page change should not fire again.
datatable page change triggers pagechanged event again. Also pageInfo.page restting to zero,
async pageChanged(pageInfo: MdbPaginationChange) {
console.log(pageInfo)
if (pageInfo.page == 0) {
this.companies = await this.companyService.getInitialRows(pageInfo);
}
else
if (pageInfo.page > this.companyService.lastPageNumber()) {
this.companies = await this.companyService.getNextRows(pageInfo);
}
else
if (pageInfo.page < this.companyService.lastPageNumber()) {
this.companies = await this.companyService.getPreviousRows(pageInfo);
}
}
companyservice.ts:
async getNextRows(pageInfo:any) {
if (!this.lastVisible) return [];
this.lastPageNumber.set(pageInfo.page);
const companiesCollection = collection(this.db, 'lmscompanies');
const q = query(
companiesCollection,
orderBy('companyName'),
startAfter(this.lastVisible),
limit(pageInfo.entries)
);
const querySnapshot = await getDocs(q);
if(querySnapshot.size==0)
return []
this.currentDocs = querySnapshot.docs;
this.firstVisible = querySnapshot.docs[0];
this.lastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
return this.currentDocs.map(doc => doc.data());
}
Add comment
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: MDB5 7.0.0
- Device: PC
- Browser: Chrome
- OS: Windows 11
- Provided sample code: No
- Provided link: No