Force Trigger Refresh

I am trying to force trigger a refresh in my React plugin code so that when I press a button a refresh occurs and therefore updates the grafana widgets.

The current implementation that I have tried is using location service.

    locationService.partial({});

I can confirm that my button listener is working correctly, but this specific code doesnt seem to do anything.

How can I trigger a refresh?

You can use the reload option:


import { locationService } from '@grafana/runtime';

const refreshMe = () => {
    console.log("refresh!");
    locationService.reload();
  }

return (
      <Button onClick={refreshMe}/>
)

The partial option only appends to the current url but doesn’t trigger a refresh.

If you are adjusting parameters, calling partial then reload will also work, and the new params (possibly template variables?) would be processed,.

1 Like