refreshAll with BackEndDataProvider

Hello.
I am having a problem understanding how the BackEndDataProvider interface works with lazy loading.
I created a class that implements BackEndDataProvider and have the fetch() and size() overrides working great. They correctly pull the data from the back end using Offset and Limit to get the correct grid data page.

The problem I am having is with refreshAll() override. This is a void.
I have other criteria in the page that requires a call back to the server to update the current data. All the calls I make to the server require Offset and Limit to get the correct grid data page.

eclipse’s Quick fix hint says is needs DataProvider<PartnerDevice, PartnerApiFilter>.refreshAll(); but that makes no sense.

How do I tell the grid the data has changed and update?
How is refreshAll() supposed to work?

Thank you,

  • Jon

Hi,

How do I tell the grid the data has changed and update?
How is refreshAll() supposed to work?

If you’re updating a row, you can call grid.getDataProvider().refreshItem(newItem);
It will refresh the old item to the new one. (YourBean class must define equals and hashcode)

If you’re deleting a row or adding a row, you can call grid.getDataProvider().refreshAll();
The grid will run the size() and fetch the needed data.

Note: Instead of implementing the BackEndDataProvider interface, you might want to extend AbstractBackEndDataProvider instead. There you’ll only need to implement fetchFromBackEnd and sizeInBackEnd.

Jean-Christophe Gueriaud:
Hi,

How do I tell the grid the data has changed and update?
How is refreshAll() supposed to work?

If you’re updating a row, you can call grid.getDataProvider().refreshItem(newItem);
It will refresh the old item to the new one. (YourBean class must define equals and hashcode)

If you’re deleting a row or adding a row, you can call grid.getDataProvider().refreshAll();
The grid will run the size() and fetch the needed data.

Thank you Jean-Christophe, end the end I extended the AbstractBackEndDataProvider which eleminates the need to call the refreshAll() method on the interface. Thank you for the quick answer.
-Jon

Olli Tietäväinen:
Note: Instead of implementing the BackEndDataProvider interface, you might want to extend AbstractBackEndDataProvider instead. There you’ll only need to implement fetchFromBackEnd and sizeInBackEnd.

Thank you Olli. I did ended up extending the AbstractBackEndDataProvider. Which, as you stated, eliminated the need to call the refreshAll() method on the interface.
Thank you for the quick answer.
-Jon