Hi I'm trying to add pagination to EJS Grid while binding data from API.
Issue:
Pagination total Records is not working. The API by default returns the following JSON:
counted: 4162
isLastPage: false
variantGroups: [
{thumbnail: '/images/CA2211', id: 'CA209', name: 'Earbuds', isExpired: false, price: 275, profit: 55, availability: 'available'}, {...},{...},....]
Total number of results for the response.variantGroups is 10. So the pagination totalRecordCount is 10 only and not 4162. So can't paginate between the pages when I have only 10 records.
HTML Code:
Component:
@ViewChild('ejsGrid') ejsGrid: GridComponent;variantGroups;primaryVariants;pageSettings = { pageSizes:true, pageSize:10 };pageSize = 10;page = 1;ngOnInit(): void {this.getProducts();}getProducts() {this.http.post(`https://example.com/api/variantGroup/list`, {pageSize:10,page:1,filter: {country:'EGY',},}).subscribe((response: any) => {this.variantGroups = response.variantGroups;this.primaryVariants = this.variantGroups.map(variantGroup=>variantGroup.primaryVariant);});}pageChange(event) {constobj = {pageSize:this.ejsGrid.pageSettings.pageSize,page:this.ejsGrid.pageSettings.currentPage,};if (event.requestType === 'paging') {this.pageSize = obj.pageSize;this.page = obj.page;this.getProducts();}}
Things I've tried:
In the component
I even tried to add a static number like 300, 400 just to test but it doesn't work. What would be the ideal way to make this work?