How to refresh the dashboard from code?

Hi,

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';

appEvents.emit(PanelEvents.refresh);

It happens nothing. Have anyone another solution.

1 Like

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

getTimeSrv().refreshDashboard();

1 Like

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