Main Function:
/**
* Calculate the new page index when items per page changed
* @param currentPageIndex Current Page Index
* @param currentRowsPerPage Current Rows Per Page
* @param newRowsPerPage New Rows Per Page
* @return New page index.
*/
private int newPageIndex(int currentPageIndex, int currentRowsPerPage, int newRowsPerPage)
{
int currentTopIndex = (currentPageIndex-1)*currentRowsPerPage+1;
int newPageIndex = currentTopIndex%newRowsPerPage > 0 ?
(currentTopIndex/newRowsPerPage)+1:
currentTopIndex/newRowsPerPage;
return newPageIndex;
}
* Calculate the new page index when items per page changed
* @param currentPageIndex Current Page Index
* @param currentRowsPerPage Current Rows Per Page
* @param newRowsPerPage New Rows Per Page
* @return New page index.
*/
private int newPageIndex(int currentPageIndex, int currentRowsPerPage, int newRowsPerPage)
{
int currentTopIndex = (currentPageIndex-1)*currentRowsPerPage+1;
int newPageIndex = currentTopIndex%newRowsPerPage > 0 ?
(currentTopIndex/newRowsPerPage)+1:
currentTopIndex/newRowsPerPage;
return newPageIndex;
}