I have a dashboard that contains a textbox amoung other things. Im using it to pause PRTG alarms.
Would it be possible to get auto suggestions on device names as I type them? Ex. I type ADSYNC and all devices that contains ‘ADSYNC’ in the name would be shown in a dropdown list or something like that.
The devices could come from a csv file or something similar. Would that be possible?
But I can’t seem to figure out how to incorperate it into my current dashboard code.
Is is my textbox:
$Pages += New-UDPage -Name 'Pause PRTG devices' -Content {
#Creating a new row on the dashboard.
New-UDRow -Columns {
#Creating a new column on the dashboard.
New-UDColumn -SmallSize 3 -LargeSize 6 -Content {
#Card Creation.
New-UDCard -Title 'Hvor længe skal der pauses' -TitleAlignment 'Center' -Content {
#Creating a new row in the form.
New-UDRow -Columns {
#Creating a new column in the form.
New-UDColumn -LargeSize 6 -Content {
#Textbox in the column.
New-UDTextbox -ID 'DeviceName' -Label 'Device der skal pauses'
New-UDTextbox -ID 'Message' -Label 'Bekrivelse'
}
I want the New-UDAutocomplete to work with New-UDTextbox -ID ‘DeviceName’
How do I make New-UDAutocomplete work with that textbox? Or does it not work like that?
Edit: Maybe I need to add a module or component? but nothing shows up when I search for autocomplete
New-UDAutocomplete replaces New-UDTextbox. In the OnLoadOptions parameter, you would supply an object of items to choose from. Using your snippet, I replaced the textbox with the autocomplete and gave an example of an object called $devices that would be populated.
$Pages += New-UDPage -Name 'Pause PRTG devices' -Content {
#Creating a new row on the dashboard.
New-UDRow -Columns {
#Creating a new column on the dashboard.
New-UDColumn -SmallSize 3 -LargeSize 6 -Content {
#Card Creation.
New-UDCard -Title 'Hvor længe skal der pauses' -TitleAlignment 'Center' -Content {
#Creating a new row in the form.
New-UDRow -Columns {
#Creating a new column in the form.
New-UDColumn -LargeSize 6 -Content {
#Textbox in the column.
New-UDAutocomplete -ID 'DeviceName' -Label 'Device der skal pauses' -OnLoadOptions { @($Devices) | Where-Object { $_ -like "*$Body*" } | ConvertTo-Json
New-UDTextbox -ID 'Message' -Label 'Bekrivelse'
}