I have a table component on a perspective view and created a query binding to the data of the component.'
I want to create a radio group called "Auto Refresh" with the values of "On" and "Off". When "On" is selected, I want it to refresh the table component every 60 seconds automatically. How can this be done?
I thought about a gateway timer script but that applies to the overall environment rather than a particular user running a page in their session. I thought about using polling but I have multiple transform steps after the query. So, I want to refresh the whole binding. Also, I didn't a way to dynamically turn the polling off.
Any ideas on how to solve this problem?
I would use an Expression binding with "now(60000)" and a Script Transform. Then, if your auto-refresh toggle is true, you can use system.db.runNamedQuery(), return the results and apply further Transforms.
1 Like
Regarding the binding: you can't enable or disable it programmatically. It has been discussed several times. See Dynamic Enable / Disable Perspective Query Binding?, for example.
Regarding your radio group: I suggest that it's the wrong component for the job. You're setting a boolean so use either a Toggle Switch component or a Checkbox component as would be done on mobile phone apps, etc. Your users know how they work!
Radio group
Toggle switch.
Less cluttered and you save on real-estate.
Thanks. It worked perfectly!
Great suggestion. The toggle switch is a much better option.
A workaround assuming that you're using a Query Binding (and that I've convinced you to use a toggle switch):
if(
{../ToggleSwitch.props.selected},
3, // Every 3 s
32000000 // "Never again!"
)
Set the Never Again value to more seconds than your server could stay running or enough to get you past retirement. I didn't bother to work it out.
No script - just an expression!
1 Like