Select
Select component for Universal Dashboard
Select components are used for collecting user provided information from a list of options.

Simple Select

Create a simple select with multiple options.
1
New-UDSelect -Option {
2
New-UDSelectOption -Name 'One' -Value 1
3
New-UDSelectOption -Name 'Two' -Value 2
4
New-UDSelectOption -Name 'Three' -Value 3
5
}
Copied!

Grouped Select

Create a select with groups of selections.
1
New-UDSelect -Option {
2
New-UDSelectGroup -Name 'Group One' -Option {
3
New-UDSelectOption -Name 'One' -Value 1
4
New-UDSelectOption -Name 'Two' -Value 2
5
New-UDSelectOption -Name 'Three' -Value 3
6
}
7
New-UDSelectGroup -Name 'Group Two' -Option {
8
New-UDSelectOption -Name 'Four' -Value 4
9
New-UDSelectOption -Name 'Five' -Value 5
10
New-UDSelectOption -Name 'Size' -Value 6
11
}
12
}
Copied!

OnChange

Execute a PowerShell event handler when the value of the select is changed.
1
New-UDSelect -Option {
2
New-UDSelectOption -Name 'One' -Value 1
3
New-UDSelectOption -Name 'Two' -Value 2
4
New-UDSelectOption -Name 'Three' -Value 3
5
} -OnChange { Show-UDToast -Message $EventData }
Copied!

Get-UDElement

Retrieve the value of the select from another component.
1
New-UDSelect -Option {
2
New-UDSelectOption -Name 'One' -Value 1
3
New-UDSelectOption -Name 'Two' -Value 2
4
New-UDSelectOption -Name 'Three' -Value 3
5
} -Id 'select' -DefaultValue 2
6
7
New-UDButton -Text 'OnBoard' -OnClick {
8
$Element = Get-UDElement -Id 'select'
9
if ($Element.Value)
10
{
11
Show-UDToast -Message $Element.Value
12
}
13
else
14
{
15
Show-UDToast -Message $Element.DefaultValue
16
}
17
}
Copied!
New-UDSelect
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Option
ScriptBlock
Options to include in this select. This can be either New-UDSelectOption or New-UDSelectGroup.
false
Label
String
The label to show with the select.
false
OnChange
Endpoint
A script block that is executed when the script changes. $EventData will be an array of the selected values.
false
DefaultValue
String
The default selected value.
false
Disabled
SwitchParameter
Whether this select is disabled.
false
Multiple
SwitchParameter
Whether you can select multiple values.
false
Last modified 6mo ago