impi1111
impi1111

Reputation: 1

Vaading setAllRowsVisible, lazy loading grid

Im using Vaadin 24. Currently I have grid which is using CallbackDataProvider to lazy load the data from database, but problem is that I want this grid on whole page not just as a seperate table, so I used grid.setAllRowsVisible(true) to put it directly on the page with all rows, and until I used lazy loading everything worked fine, but now I implemented mentioned above CallbackDataProvider, and seems like grid.setAllRowsVisible is taking amount of rows from CountCallback<T, F> countCallback and base on that is creating one big Grid instead of lazy generating it.

Is there a way to say to grid to take data from FetchCallback<T, F> fetchCallback instead? Or maybe there is a different option for handling this.

Everything explained above.

Upvotes: 0

Views: 168

Answers (1)

Tatu Lund
Tatu Lund

Reputation: 10643

Using grid.setAllRowsVisible(true) will disable lazy loading feature, that exactly the point of this API. It is also stated in the documentation. If you indeed need lazy loading and especially callback fetches, you should not use it.

/**
 * If <code>true</code>, the grid's height is defined by its rows. All items
 * are fetched from the {@link DataProvider}, and the Grid shows no vertical
 * scroll bar.
 * <p>
 * Note: <code>setAllRowsVisible</code> disables the grid's virtual
 * scrolling so that all the rows are rendered in the DOM at once. If the
 * grid has a large number of items, using the feature is discouraged to
 * avoid performance issues.
 *
 * @param allRowsVisible
 *            <code>true</code> to make Grid compute its height by the
 *            number of rows, <code>false</code> for the default behavior
 */
public void setAllRowsVisible(boolean allRowsVisible)

Upvotes: 3

Related Questions