So I’m playing around with the new cmdlet for data grids (New-UDDataGrid) and I can’t seem to get the content to render on my dashboard when trying to populate data dynamically.
I’m not sure if it’s a bug or if I’m doing something wrong, but I get the same behavior if I just copy the example code from the custom columns example in the documentation here.
Here’s what the example looks like
New-UDDataGrid -LoadRows {
$Rows = 1..100 | % {
@{ Name = 'Adam'; Number = Get-Random}
}
@{
rows = $Rows
rowCount = $Rows.Length
}
} -Columns @(
@{ field = "name"; render = { New-UDTypography -Text $EventData.number }}
@{ field = "number"}
) -AutoHeight
And the output
Here’s my code
New-UDDataGrid -LoadRows {
$Data = @($JobOutput | Where-Object {$_.'Assigned_To' -eq "$($User -replace '\.',' ')"}) | ForEach-Object {
@{Ticket_Number = $_.Ticket_Number; Summary = "$($_.Summary)"}
}
@{
rows = $Data
rowCount = $Data.Length
}
} -Columns @(
@{field = "Ticket_Number"}
@{field = "Summary"}
) -AutoHeight
}
Just for some added context, the $JobOutput variable has 2 objects inside of it. If you were to output the hashtable from -LoadRows you get this output:
Name Value
---- -----
rows {System.Collections.Hashtable, System.Collections.Hashtable}
rowCount 2
But looking at the example code, I should be getting a comma-seperated list of the ‘Name’ column as shown below:
Name Value
---- -----
rows {Adam, Adam, Adam, Adam…}
rowCount 100
If I rename my Ticket_Number column to Name instead, I get the same output now:
Name Value
---- -----
rows {12345, 67890}
rowCount 2
Name Value
---- -----
Name 12345
Summary Help With Desk Phone
Name 67890
Summary New Computer Question
New-UDDataGrid -LoadRows {
$Data = @($JobOutput | Where-Object {$_.'Assigned_To' -eq "$($User -replace '\.',' ')"}) | ForEach-Object {
@{Name = $_.Ticket_Number; Summary = "$($_.Summary)"}
}
@{
rows = $Data
rowCount = $Data.Length
}
} -Columns @(
@{field = "Name"}
@{field = "Summary"}
) -AutoHeight
}
I’m not sure if it’s even related, but that was the only guess I had to as why it wouldn’t work. I’m in the 7.2.5 environment.
If I use the basic example with 3 rows with the Name and Number columns, that’s the only one that I can get to work, but anything involving custom data outputs I can’t get to work for some reason.
Product: PowerShell Universal
Version: 3.2.0