How to refresh the dashboard from code?


I want to trigger the reload event in my panel. In our company we a software where can create rules. These rules will generate data and afterwards it will save it to a database. I have a panel with a button which will trigger one rule. Afterwards i clicked the button, then i want to reload the dashboard to see the data in the other graphics.

I tried it with this, but this didn’t work.

// @ts-ignore
import appEvents from 'grafana/app/core/app_events';
import { PanelEvents } from '@grafana/data';


It happens nothing. Have anyone another solution.

1 Like

Try this:
import { getTimeSrv } from ‘app/features/dashboard/services/TimeSrv’;


1 Like

This is not possible with the react panels. I thought that Grafana have this “getTimeSrv” in a API Reference.

I also have issues reloading the dashboard from my panel. The workflow is as follows: The user clicks on a button for a data item, which sets a flag on this data item in the backend. If the flag is set successfully, I want to refresh the data in the panel to have the most current state.

I also tried the code snippet above, but for me it also did not work. As the emit function is declared as legacy, I also tried appEvents.publish instead of emit, still nothing is happening.

I don’t see the mentioned getTimeSrv anywhere in the Grafana code base.

I also noticed that PanelEvents.refresh is declared as a legacy event, is there any other event I could trigger? I tried the DashboardPanelsChangedEvent and the `PanelQueriesChangedEvent, but this only triggered an error (“not a constructor”).

Any ideas?