Hello,
I’m writing a Datasource plugin with grafana “^9.3.8”.
I don’t find a callback ‘on variable change’ to update the content of other variables in the datasource.ts.
More context:
That plugin contains a QueryVariableEditor that allow to create several kinds of variables :
For the simulations, it allows to select a Simulator variable to link it => We retrieve the simulations of a specific simulator by request.
It works perfectly while I create the variables. Now I would like to update the option list dynamically when the user is in the dashboard.
For example, I select the simulator 3390… and the content of the simulationVariable adapt itself to have only the simulations of that simulator 3390…
I don’t find the callback ‘on variable change’ to update the content of other variables in the datasource.ts.
I noticed when the variable is used in the QueryEditor, the function metricFindQuery is called. I can then update the content list by using:
getTemplateSrv().getVariables().forEach((variable) => {
if (variable.type == 'query') {
variable.options = // New list of options
}
}
But it seems wrong. And that solution is not completely satisfying as i have to used the variable in the query editor.
Thank you in advance for your help
Loïc.