I wrote swap logic:
My requirement: total number of elements to display: 100 per page, if I click on next, it should display the next 100 entries, if I click on the previous 100 entries.
Initial variability values:
- showFrom: 1,
- showTo: 100
- Maximum Elements: Depends on the size of the data.
- PAGESIZE :. 100
the code:
if(paging.getAction().equalsIgnoreCase("Next")){ paging.setTotalRec(availableList.size()); showFrom = (showTo + 1); showTo = showFrom + 100- 1; if(showTo >= paging.getTotalRec()) showTo = paging.getTotalRec(); paging.setShowFrom(showFrom); paging.setShowTo(showTo); } else if(paging.getAction().equalsIgnoreCase("Previous")){ showTo = showFrom - 1; showFrom = (showFrom - 100); paging.setShowTo(showTo); paging.setShowFrom(showFrom); paging.setTotalRec(availableList.size()); }
Here I can delete and add items to existing data. The new code works fine if I add and remove multiple elements. But if I delete or add 100 elements at a time, then the counts are not displayed correctly; the code works fine if I add and remove several elements.
source share