Hi All,
i create a custom datasource and i’m using it for filling a Table (OOTB grafana table). For now it is working fine but i have to do an enhancement, the datasource should be filtered according to a variable so after the variable change the table should refresh with the new “filtered” content.
Unfortunately when i change the variable value there is no refresh (i should manually trigger a refresh).
How can i specify that my datasource could change response according a variable so if a variable change the data from datasource should be refresh?
Thank you so much.
Hello,
In your OnChange you can put a onRunQuery()
Nicolas
Hi Nicolas,
as far as i know onchange is called only in configuration. Am i right?
Regards
Carlo
Hmm, can you send me your query editor, im using a select so i have an onchange in this.
Nicolas
If you do replaceVariables
inside the Data Source, it won’t trigger the update when the variable is refreshed.
The Query Editor for the Data Source variable should have a text input, which uses the variable, and then you can do replaceVariables
from it.
My problem is no during the edit mode. When I have already configured a table with my custom datasource if user change the value of a variable i want to refresh the content of the table.
This is what I was saying, and it works for our data sources.
- Variable change will trigger Data source update.
- Data Source should use a Variable in the Input box to retrieve data.
- Data change in Data Source will trigger Table refresh.
Hi, I’m also struggling with this.
I have a custom backend datasource with the query editor etc.
I have a text field in the query editor, I have the ${myvar} as a value in that field, but when I change the dashboard variable myvar (text field variable), datasource is triggered, i.e. it runs the query against the backend process, but with the old value of the variable.
So I guess what I should ask - is there a hook I should subscribe to in order to refresh the result of templateSrv.replace(…) for the field value before the query is submitted to the backend process?