Out-UDGridData with selectable rows?

I think I figure Something out. I at least solved the problem I set out to solve.

Import-Module UniversalDashboard

Get-UDDashboard | Stop-UDDashboard

$ProcessList = Get-Process

$theme = Get-UDTheme -Name 'DefaultTight'

$Cache:CheckBoxElementArray = @{ }

$Dashboard = New-UDDashboard -Title "Process Info" -Theme $theme -Content {

    $GridSplat = @{

        Title      = "Process Information"

        Headers    = @(' ', "Select", "Name", "Id", "Handles", "Info")

        Properties = @(' ', "Select", "Name", "Id", "Handles", "info") # Case must match PSCO

        Endpoint   = {

            $Cache:CheckBoxElementArray = @{ }

            $ProcessList | Select-Object | ForEach-Object {

                [PSCustomObject]@{

                    Select  = New-UDCheckbox -Id $_.Id -OnChange (

                        New-UDEndpoint -Endpoint {

                            $CheckBoxElement = Get-UDElement -Id $_.Id

                            $Cache:CheckBoxElementArray[$_.Id] = @{

                                Checked = $CheckBoxElement.Attributes["checked"]

                                Name    = $_.ProcessName

                                Id      = $_.Id

                                Handles = $_.Handles

                            }

                        })

                    Name    = $_.ProcessName

                    Id      = $_.Id

                    Handles = $_.Handles

                    info    = New-UDButton -Text "Info" -OnClick (New-UDEndpoint -Endpoint {

                            Show-UDModal -Content {

                                New-UDTable -Title "Info" -Headers @( "Process Name", "Process Id", "Handles")  -Content {

                                    Get-Process -Id $_.Id | ForEach-Object {

                                        [PSCustomObject]@{

                                            Handles = $_.Handles

                                            Name    = $_.ProcessName

                                            Id      = $_.Id

                                        }

                                    } | Out-UDTableData -Property @(  "Name", "Id", "Handles")

                                }

                            }

                        })

                }

            } | Out-UDGridData

        }

    }

    New-UDButton -Text "Select Process" -OnClick (New-UDEndpoint -Endpoint {

            Show-UDModal -Height '60%' -Width '90%' -Content {

                New-UDGrid @GridSplat -PageSize 5

                New-UDButton -Text "Show Selections" -OnClick (

                    New-UDEndpoint -Endpoint {

                        Show-UDModal -Content {

                            New-UDTable -Title 'Selected' -Headers @("Name", "Id", "Handles") -Content {

                                foreach ($Key in $Cache:CheckBoxElementArray.Keys) {

                                    [PSCustomObject]@{

                                        Name    = $Cache:CheckBoxElementArray[$key]['Name']

                                        Id      = $Cache:CheckBoxElementArray[$key]['Id']

                                        Handles = $Cache:CheckBoxElementArray[$key]['Handles']

                                    } | Out-UDTableData -Property @("Name", "Id", "Handles")

                                }

                            }

                        }

                    }

                )

            }

        })

}

Start-UDDashboard -Dashboard $Dashboard -Port 10001
3 Likes