@stoni1989 one thing I can pretty much say for sure is anything is possible in UD that’s why I am such a supporter of this software module the mighty @adam released…ok so just for clarification I have a working version here is my selection list…that works…
New-UDCard -BackgroundColor "#8789c0" -Endpoint {
$query = @"
SELECT [ProductCode]
,[ProductName]
FROM COMPANY_DB
"@
$Products = Invoke-Sqlcmd2 -ServerInstance COMPANY_SERVER -Database COMPANY_DB -Query $query -Username USERNAME -Password PASSWORD
$hash = @()
foreach($item in $Products) {
$hash += @{
value = $item.ProductName
label = $item.ProductCode
}
}
New-UDSelector -id "selector1" -Options {
$hash
} -PlaceHolder "Select Product Codes..."
}
I am importing the invoke-sqlcmd2 from a function I import into my dashboard…now you need some sort of button to obtain the selected results to then pass onto something else…this is how you do that…
New-UDButtonParticle -Id "Explode3" -Text "Search" -Color "#2e3d55" -BackgroundColor "#2e3d55" -Icon search -onClick {
function Get-UDSelectorValue {
param($SelectorId)
$value = (((Get-UDElement -Id $SelectorId).Attributes.selectedOption | Select-Object Root -ErrorAction SilentlyContinue) | ConvertTo-Json -Depth 2 | ConvertFrom-Json | Select-Object -ExpandProperty Root -ErrorAction SilentlyContinue) | Select-Object -First 1
if (!$value) {
$val = ((Get-UDElement -Id $SelectorId).Attributes.selectedOption | ConvertTo-Json -Depth 1 | ConvertFrom-Json | Select-Object -ExpandProperty SyncRoot) | Select-Object -ExpandProperty SyncRoot
$length = $val.length
$i = 0
Do {
if (($i % 2) -eq 0) {
$value += "'$($val[$i])'" + ","
}
$i++
}
While ($i -le $length)
$value = $value.TrimEnd(",")
}
return $value
}
$Selected = (Get-UDSelectorValue -SelectorId 'selector1') -replace ",''"
if (($Selected) -notmatch "\A'" )
{
$Selected = "'$Selected'"
}
Show-UDToast -Message "You selected $Selected" -duration 5000 -Position center
###sync other elements of your dashboard with this data
@("GridData9","InsideGrid9","pivot3") | Sync-UDElement
start-sleep -Seconds 5
}
So in this example PLEASE PLEASE note the ID parameter is crucial, it gets the selected values from the UDSelector then puts them in a $Session variable to then be passed to other objects on the dashboard to be populated with this information…I hope this all makes sense? This code is working without issues for me.
P.S the button particle is another component I pushed to the marketplace
So here is a demo from the dashboard, I had to stop recording at the end as sensitive information…but it populates a grid and a pivot table from the product codes selected and the date range selected…which is dynamically updated by sync’ing the rest of the components on the page with the information gathered from the select and date selection.
The select list is holding thousands of items