Hello,
is it possible to disable a New-UDSelect element with Set-UDElement ?
For a performance reason, I cannot use Sync-UDElement, I need to update the select elements from the client side.
Hello,
is it possible to disable a New-UDSelect element with Set-UDElement ?
For a performance reason, I cannot use Sync-UDElement, I need to update the select elements from the client side.
You should be able to like this:
New-UDSelect -Id 'SelectID' -Option {
New-UDSelectOption -Name 'One' -Value 1
New-UDSelectOption -Name 'Two' -Value 2
New-UDSelectOption -Name 'Three' -Value 3
}
New-UDButton -Text 'Disable' -OnClick { Set-UDElement -Id 'SelectID' -Attributes @{Disabled = $True}}
Thank you it works
But how can I select an option in the same way ?
Tried value = 2 instead of Disabled = $True without success
You can set the DefaultValue property with that method but it will not update on the page. You would need to wrap the selection around New-UDDynamic, change the variable, and then sync the element. You can do something like this:
$session:Default = 1
New-UDDynamic -Id 'UpdateSelection' -Content {
New-UDSelect -DefaultValue $session:Default -Option {
New-UDSelectOption -Name 'One' -Value 1
New-UDSelectOption -Name 'Two' -Value 2
New-UDSelectOption -Name 'Three' -Value 3
}
}
New-UDButton -Text 'Update Value' -OnClick {
$session:Default = 2
Sync-UDElement -Id 'UpdateSelection'
}
Hello, thank you but I can’t use New-UDDynamic and Sync-UDElement because of a performance issue. I need to use the client side the most possible.
The user must choose an organisation with 4 selectboxes (direction department service lab), and the content of each selectbox depends of the value selected in the previous selectbox.
If the New-UDDynamic / Sync-UDElement method is enough on a page, the performance fall when used inside a modal element.
And basically our PSU server responds with some latency to our client computers because of its physical location ( another site ).
I find that I can set the value using Set-UDElement. It’s a bit problematic because the displayed value doesn’t change but the internal value does change. You can verify the behavior like this.
New-UDSelect -Id 'SelectID' -Option {
New-UDSelectOption -Name 'One' -Value 1
New-UDSelectOption -Name 'Two' -Value 2
New-UDSelectOption -Name 'Three' -Value 3
}
New-UDButton -Text 'Disable' -OnClick {
Set-UDElement -Id 'SelectID' -Attributes @{Disabled = $True; Value = "3" }
}
New-UDButton -Text 'Value' -OnClick {
Show-UDToast (Get-UDElement -Id 'SelectID').Value
}
Hi @sandy37 i know im a little late to the party but i built this a while back
I know you got an answer but sure this component would work for you