GWT SimplePager LastButton Problem

I ran into a problem with lastButton of SimplePager. I have 3 pages in a cellular table, page size = 11 (1 blank entry + 10 entries (with value)), total entry = 26.

I used CustomerPager by expanding SimplePager.

In the first attempt, 1 + 10 entries in the table will be displayed: the "Next" and "Last page" buttons are pressed (the "First and previous" button is disabled), which is correct. But the LastPage button does not work ... :( I do not know what the problem is ... (the event does not fire)

Strange behavior:

@ 1 The last page button only works when visiting the last page (3 pages in my case).

@ 2 Suppose I am on the first page n I went to the second page (total 3 pages in the cell table). at this time, all buttons are on, which is correct. In this case, the last button works, but behaves like the next button

The GWT application integrated into one of our products cannot debug it from the client side.

Maybe the index value is incorrect in the setPage (int index) method of AbstractPager

The code flow is as follows for the last button

//From SimplePager lastPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { lastPage(); } }); @Override public void lastPage() { super.lastPage(); } // From AbstractPager /** * Go to the last page. */ protected void lastPage() { setPage(getPageCount() - 1); } protected void setPage(int index) { if (display != null && (!isRangeLimited || !display.isRowCountExact() || hasPage(index))) { // We don't use the local version of setPageStart because it would // constrain the index, but the user probably wants to use absolute page // indexes. int pageSize = getPageSize(); display.setVisibleRange(pageSize * index, pageSize); } } 

or there may be some false values ​​from the code above (from setPage ())

actual record = 26 and 3 Blank record (1st blank record / page)

There may be a problem with dataSize: |

How can I check the number of pages based on the size of the data?

How can I solve this problem?

+4
source share
4 answers

Only cellTable.setRowCount(int size, boolean isExact) to the OnRange AsyncDataProvider change method. My problem is resolved :)

 protected void onRangeChanged(HasData<RecordVO> display) { //----- Some code -------- cellTable.setRowCount(searchRecordCount, false); //----- Some code -------- } 
0
source

edit: I found out that the default constructor of the pager does not give you the "last" button, but instead of the "Fast forward 1000 lines" key (terrible, right?).

call the following constructor, for example, and consider your problem:

SimplePager.Resources resources = GWT.create(SimplePager.Resources.class); SimplePager simplePager = new SimplePager(TextLocation.CENTER, resources , false, 1000, true);

the first false flag disables the quick button, and the last true flag enables the last button.

also the last button will work only if the pager knows the total number of records that you have.

you can call the setRowCount function of the table to update the final value like this:

int totalRecordsSize = 26; //the total amount of records you have boolean isTotalExact = true; //is it an estimate or an exact match table.setRowCount(totalRecordsSize , isTotalExact); //sets the table total and updates the pager (assuming you called pager.setDisplay(table) before)

if you are working with an attached DataProvider, instead use the updateRowCount method (same use) instead.

+3
source

Seeing no more of your code, this is a difficult question to answer, as there may be several places where everything goes wrong.

I would make sure you call setDisplay(...) on your SimplePager, so it has data that it needs to calculate ranges.

If you cannot work in devmode, I recommend setting up some GWT logging in the browser (write logs to a popup panel or something else, see this discussion for an example).

0
source

I think the problem is with the condition in setPage() . Try to put SOP before if or debug code

0
source

Source: https://habr.com/ru/post/1402822/


All Articles