Fix paging and pagination to work with client side filtering

For #2211. For pagination, it changes the totalPages, second commit changes to the currentPage in paging also.