viritin / flow-viritin

Viritin inspired project for Vaadin Flow
Other
43 stars 16 forks source link

PagingGrid incorrect total page number #25

Closed weiliang2 closed 2 years ago

weiliang2 commented 4 years ago

Hello,

i think there is a issue with this part of the code. if the size is 291 for instance and page size is 50 291/50 is 5.82. we are taking 5 and missing the last part of the page.


void setSize(Long s) {
    this.size = s;
    if (sizeKnown()) {
        pages = (size / getPageSize());
    }
}

also for this, i think it would be good to add in another variable to let user know how many item are return each from each page


private void updateState() {

            final boolean hasPrev = currentPage > 0;
            first.setEnabled(hasPrev);
            previous.setEnabled(hasPrev);
            if (sizeKnown()) {
                final boolean hasNext = currentPage < pages - 1;
                last.setVisible(true);
                last.setEnabled(hasNext);
                next.setEnabled(hasNext);
                status.setText("Page " + (currentPage + 1) + "/" + pages + ", showing " + getPageSize()
                        + " results per page.");
            } else {
                last.setEnabled(false);
                next.setEnabled(true);
                status.setText("Page " + (currentPage + 1) + ", showing " + getPageSize() + " results per page.");
            }
        }
mstahv commented 4 years ago

Nice catch, do you have a chance to create a pull request to get those fixed?