Why My Next And Previous Control Not Able To Take The Correct Index When Paginating? What Changes Do I Need To Make?
In my code when you click on any of the record you will see the details. In the details there are 2 links (previous, next) to navigate to previous n next record. On the first page
Solution 1:
find working example here in this StackBlitz Link
I have added new parameter inside viewuser()
<tr class="record-row" (click)="viewUser(user, i, filteredUsers, 5, page)"
and inside viewUser()
viewUser(user: any, index, filterData, itemsPerPage, currentPage) {
console.log(itemsPerPage, currentPage);
let currentPageIndex = currentPage;
let recordPerPageToShow = itemsPerPage;
let findCurrentRecordToSkip = (currentPageIndex - 1) * recordPerPageToShow;
let countIndex = findCurrentRecordToSkip + recordPerPageToShow;
console.log(
"filter-pagination",
filterData.slice(findCurrentRecordToSkip, countIndex)
);
this.isView = true;
console.log(user, index, filterData);
this.userObj = user;
this.currentIndex = index;
this.allUserTableData = filterData.slice(
findCurrentRecordToSkip,
countIndex
);
}
Post a Comment for "Why My Next And Previous Control Not Able To Take The Correct Index When Paginating? What Changes Do I Need To Make?"