New-UDTable -OnRowStyle not working - row coloring not applied (even with documentation example)
Product: PowerShell Universal Version: 5.6.8
Hello,
I’m experiencing an issue with the -OnRowStyle parameter in New-UDTable. The row coloring functionality is not working, even when using the exact code from the documentation.
Problem
The -OnRowStyle parameter doesn’t apply background colors to table rows, even though the script block executes and returns the correct style hashtable.
Steps to Reproduce
New-UDPage -Url "/TestTable" -Name "TestTable" -Role @('Administrator', 'Tester') -Content {
$Data = @(
@{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 1; Protein = 4.0 }
@{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 150.0; Carbs = 34; Protein = 4.0 }
@{Dessert = 'Eclair'; Calories = 159; Fat = 100.0; Carbs = 73; Protein = 4.0 }
@{Dessert = 'Cupcake'; Calories = 159; Fat = 30.0; Carbs = 25; Protein = 4.0 }
@{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 99; Protein = 4.0 }
)
$Columns = @(
New-UDTableColumn -Property Dessert -Title "Dessert"
New-UDTableColumn -Property Calories -Title "Calories"
New-UDTableColumn -Property Fat -Title "Fat"
New-UDTableColumn -Property Carbs -Title "Carbs" -DefaultSortColumn
New-UDTableColumn -Property Protein -Title "Protein"
)
New-UDTable -Data $Data -Id 'table14' -Columns $Columns -OnRowStyle {
if ($EventData.Fat -lt 10) { $Color = 'green' }
elseif ($EventData.Fat -ge 10 -and $EventData.Fat -lt 50) { $Color = 'Yellow' }
else { $Color = 'Red' }
@{ backgroundColor = $Color }
}
}Expected Behavior
Actual Behavior
Write-Host debugging), but styles are not applied to the UIAdditional Notes
-OnRowStyle-Dense, -MaxHeight, -DefaultSortDirection) - still doesn’t workQuestion
Is -OnRowStyle supported in the current version of PowerShell Universal? If yes, what could be causing this issue? If not, is there an alternative way to style table rows based on data values?
Thank you for your help!
strange:
im on 5.6.11 on my home instance but:
5584c8620ccaadb7fe11084e78903250ac39d733.png
Thanks.
I will update the PSU to version 5.6.12 as soon as it becomes available and test again.