DataProvider refreshAll in a Grid not working until...

I’ve a data provider extending AbstractDataProvider.
When I execute a refreshAll it does nothing until and data are not fetched.
After the Grid is shown then the refreshAll seems to work.
I suspect I call it too early but I don’t know after which event I should put my refreshAll.
Could someone help ?

You don’t know after which event? that depends of what you are allowing the users to do with the data in the grid, it would be good to refresh after adding, editing or removing something from the grid right? or some external filter that would determinate what is loaded

Tks fou your help but my problem is not to react to an user action.
I need to refresh by code before grid is shown.
When I do this the database is not queried and the refresh is useless.
Then the grid is shown and, if I do a refresh by code, it works.
I don’t know when I can trigger the refresh event in an appropriate way.

what do you mean by “then the grid is shown”? is it no added to any layout? or do you hide it with setVisible(false)? if you do the last one, check the @doc about what happens when a component is NOT visible

If you didn’t @override refreshAll() in your implementation of AbstractDataProvider, see the source, it does nothing but fireEvent (notify to the listeners), and one of the listeners is the Grid

By “the grid is shown” I mean that when I see the grid I can push a button and the refreshAll is correctly executed.
I saw and tryed to debug AbstractDataProvider but when I do the refresh it executes fireEvent and it has two listner (unfortunately with lambdas is quite difficult to understand where do they come from) but none of them fires the fetch of the data.
When the grid is shown and I push the refres button the same fireEvent executes, I see 3 listener and one of them does the job.

My problem is that, when I do the refreshAll the grid is not yet among listeners and then it does nothing.
When the grid is declared among listeners ?
If I know that I could try to put my refresh after.