UDGrid one colum for actions like restart,rdp

Hi,

i have an UDGrid with properties like Servername,LastReboot,InstallationStatus and one Action column.

I want to have more actions in the Action column, like Restart,RDP, etc

My code working with Restart action:

$Srv.Status = Get-IconFromStatus -Message β€œ$($RetVal.Status)”
$Srv.RebootRequired = $RetVal.RebootRequired
$Srv.LastWriteTime = $RetVal.LastWriteTime
$Srv.LastBootupTime = $RetVal.LastBootupTime

    $Srv.Action = New-UDElement -Tag "a" -Attributes @{ onClick = {
        Show-UDModal -Content {
            New-UDHeading -Text "Do you want to restart server $($Srv.ComputerName)"
            New-UDHtml -Markup "<br>"
            New-UDButton -Text "Restart now" -OnClick {
                Invoke-Command -ComputerName $($Srv.ComputerName) -Credential $AdminCredential -ScriptBlock {
                    Restart-Computer -Force
                }

                Hide-UDModal
            }

        }
    }
    } -Content {"Restart"}

How can i add an additional action like another UDLink to $Srv.Action column?

Thanks

I haven’t been able to solve that problem, but I ended up just using multiple columns for different actions.

In case this isn’t possible, you could also have multiple action buttons inside the modal.

Thanks for the suggestions maybe Adam can check if this is possible.

Try something this like:

$Srv.Action = New-UDLayout -Columns 3 -Content { 
       New-UDElement -Tag "a" -Attributes @{ onClick = { } }
       New-UDElement -Tag "a" -Attributes @{ onClick = { } }
       New-UDElement -Tag "a" -Attributes @{ onClick = { } }
}

Action column is now empty :frowning:

Can you verify?

Bummer. Ok. Let me give it a shot in a bit to see whats up.

actually one of the features we wish to have is the button spanning so we can add multiple buttons.
i think as a work around you can use grid and call it Available actions then create an object with your buttons.

$Srv.Action = New-UDElement -Tag "a" -Attributes @{
	onClick = {
		Show-UDModal -Content {
			New-UDHeading -Text "Do you want to restart server $($Srv.ComputerName)"
			New-UDHtml -Markup "<br>"
			New-UDGrid -Title "Available Actions" -Headers @("Restart", "Remote Control", "Shutdown") -Properties @("Restart", "RemoteControl", "Shutdown") -Endpoint {
				[pscustomobject]@{
					Restart = New-UDButton -Text "Restart now" -OnClick {
						Invoke-Command -ComputerName $($Srv.ComputerName) -Credential $AdminCredential -ScriptBlock {
							Restart-Computer -Force
						}
						Hide-UDModal
					}
					RemoteControl = New-UDButton -Text "Restart now" -OnClick {
						Invoke-Command -ComputerName $($Srv.ComputerName) -Credential $AdminCredential -ScriptBlock {
							Restart-Computer -Force
						}
						Hide-UDModal
					}
					Shutdown = New-UDButton -Text "Restart now" -OnClick {
						Invoke-Command -ComputerName $($Srv.ComputerName) -Credential $AdminCredential -ScriptBlock {
							Restart-Computer -Force
						}
						Hide-UDModal
					}
				} |Out-UDGridData
				
			}
		}
	}
} -Content { "Restart" }

This works for me.

     New-UDGrid -Title "Hi" -Endpoint {
          $Items = [PSCustomObject]@{
               Actions = New-UDLayout -Columns 3 -Content {
                    New-UDButton -Text "Hey"
                    New-UDButton -Text "Hey"
                    New-UDButton -Text "Hey"
               }
          },[PSCustomObject]@{
               Actions = New-UDLayout -Columns 3 -Content {
                    New-UDButton -Text "Hey"
                    New-UDButton -Text "Hey"
                    New-UDButton -Text "Hey"
               }
          },[PSCustomObject]@{
               Actions = New-UDLayout  -Columns 3 -Content {
                    New-UDElement -Tag "a" -Attributes @{ onClick = { } } -Content { "Hi" }
                    New-UDElement -Tag "a" -Attributes @{ onClick = { } } -Content { "Hi" }
                    New-UDElement -Tag "a" -Attributes @{ onClick = { } } -Content { "Hi" }
               }
          } 

          $Items | Out-UDGridData
          
     }

1 Like

Thx this is working for me.