I have a query that I want to auto refresh if any of the data has a certain field in a certain state. This is easily achieved with this bit of code in the Disable Query field in advanced:
The query is loading the data in the table, the table has a refresh button. I want the table to auto refresh if it has any rows with status==DEPLOYING. I want the refresh button to still be able to do deploymentsGet.trigger() when there are no rows with status==DEPLOYING
Hello, I get your means until I make the testing app.
You want to still trigger the query via click fresh button to get the data(a.k: manually) when the query is disable.
unfortunely, when the query disable, it won't response to trigger until you enable it.
Here is my workaround for your use case - use variable.
first, define a variable named autoRefresh.
and set it default value to {{deploymentsGet.data.filter(e => e.status == 'DEPLOYING').length > 0 ? false : true }}.
and set the disabled option of fresh button to {{deploymentsGet.data.filter(e => e.status == 'DEPLOYING').length > 0 ? true: false }} be notice that the true and false is change the position. That's said when autoRefresh mode is on, you can't click the refresh button.
then add the event handler to the refresh button let lastValueOf_autoRefresh = autoRefresh.value; autoRefresh.setValue(false); deploymentsGet.trigger({onSuccess: function (data) { autoRefresh.setValue(lastValueOf_autoRefresh) }, });
In this js block, every time you trigger the query, you need to enable it by setting autoRefresh.value to false firstly. Then after the trigger success, you need to restore it value to the last state[false or true].
Here is json of my test app, you can upload to create app to check it. test.json (15.2 KB)