Wednesday, March 4, 2020

GWT DataGrid getRowElement throwing IndexOutOfBoundsException after manually setting the page

I have a DataGrid, and I would like to display a row that is not in the currently visible row set, however, I get an indexOutOfBound Exception when I call getRowElement().

In my code, I determine in which page of results the desired row exists and I set the appropriate page with

  gridPager.setPage(showPage);

I then try to get the RowElement using the following, where showRow is the actual row index in the dataset.

  Range range = dataGrid.getVisibleRange();
 
int start = range.getStart();
 
int rowIdx = showRow - start;
 
TableRowElement row = dataGrid.getRowElement(rowIdx);

But that throws the indexOutOfBounds Exception.

I have also tried using the actual row index with the same result.

The page is properly set and displays the page of results that includes the desired row, but I am unable to get the RowElement in order to scroll the display.

Note that if the user has already manually paged to the page that includes the desired row, and as such the setPage() operation is not performed, I can successfully get the RowElement with this  method and scroll the view.

Runtime logging would indicate that the appropriate rows have been fetched.

Any insights into what I am missing or doing wrong would be most appreciated.

Thanks,
- Linus

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/95a0c8e4-c5c1-447e-b2e2-604c9dd4ff96%40googlegroups.com.

No comments:

Post a Comment