So I have several dashboards that have column rendering running under PowerShell 5.1. The same code works if I uninstall and go back to a version of Universal pre 3.5.0 and run the same dashboard code. To try and track down where the issue was I took one of the example tables in the documentation and added a render column.
$Data = try { get-service -ea Stop | select Name,@{n = "Status";e={ $_.Status.ToString()}},@{n = "StartupType";e={ $_.StartupType.ToString()}},@{n = "StartType";e={ $_.StartType.ToString()}} } catch {}
$Columns = @(
New-UDTableColumn -Property Name -Title "Service Name" -ShowSort -IncludeInExport -IncludeInSearch -ShowFilter -FilterType text
New-UDTableColumn -Property Status -Title Status -ShowSort -DefaultSortColumn -IncludeInExport -IncludeInSearch -ShowFilter -FilterType select
New-UDTableColumn -Property StartupType -Title StartupType -IncludeInExport -ShowFilter -FilterType select -Render {
New-UDButton -Id "btn$($EventData.StartupType)" -Text "StartupType!" -OnClick { Show-UDToast -Message $EventData.StartupType }
}
New-UDTableColumn -Property StartType -Title StartType -IncludeInExport -ShowFilter -FilterType select
)
New-UDTable -Id 'service_table' -Data $Data -Columns $Columns -Title 'Services' -ShowSearch -ShowPagination -ShowSelection -Dense -OnRowSelection {
$Item = $EventData
Show-UDToast -Message "$($Item | out-string)"
}
New-UDButton -Text "GET Rows" -OnClick {
$value = Get-UDElement -Id "service_table"
Show-UDToast -Message "$( $value.selectedRows | Out-String )"
}
This is the error in the logs (x200).
Exception calling “GetNewClosure” with “0” argument(s): “The attribute cannot be added because variable DefaultSortDirection with value would no longer be valid.”
You cannot call a method on a null-valued expression.
If I switch it to use PowerShell 7.1 then it works without issue. Any ideas?
Product: PowerShell Universal
Version: 3.5.4