Disable autorefresh UDDynamic

Disable autorefresh UDDynamic

avatar
jerome02
Disabled

In my Apps, I have a dynamic zone to automatically fill a field.

New-UDDynamic -Id 'idDynLogin' -Content {
   if ((Get-UDElement -Id "idTBPrenom").value -and (Get-UDElement -Id "idTBNom").value ) {
  $LogonFirstName = (Get-UDElement -Id "idTBPrenom").value
 ..........
 ..........
} -AutoRefresh -AutoRefreshInterval 3


I’d like to be able to disable autorefresh with a button or a checkbox, but it doesn’t work.
I used this code to disable autorefresh:

Set-UDElement -Id "idDynLogin" -Properties @{autoRefresh = $False }


Product: PowerShell Universal
Version 4.2.13


All Comments (4)

avatar

Okay so your problem is you are setting the dynamic area to auto refresh and do it every 3 seconds. Remove the two refresh parameters. Now when you want this dynamic area to display or work you need to call sync-udelement I’ve done a lot of dynamic areas recently and I set a cache variable to a certain value then sync the dynamic area but the dynamic area has an if clause to check the value of the cache variable. Hope this makes sense

avatar

ok, I understand the principle, I’ll try that.
Thanks

avatar

Hey @jerome02
I also had this need once and resolved it that way:

  • Create a Switch to enable / disable the AutoRefresh on Change:
New-UDSwitch -Id 'AutoRefresh' -Color primary -CheckStyle -Checked $false -OnChange {
	Set-UDElement -Id 'myTable' -Properties @{ 
	AutoRefresh = $((Get-UDElement -Id 'AutoRefresh').Checked)
}


  • Then use the current status of the switch in order to dynamically enable or disable the autorefresh, based on the user’s wish:
New-UDTable -Id 'myTable' -LoadData {
[...]
} -AutoRefresh:$((Get-UDElement -Id 'AutoRefresh').Checked) -AutoRefreshInterval $AutoRefreshInterval


That should do the trick. Hope this helps you a little bit.

BR,
Don

avatar

thanks