Table differences between v2 and v3

Product: PowerShell Universal
Version: 2.3.1

I am doing some work in converting my v2 dashboards to v3 dashboards. In the v2 dashboards, I would create a hashtable with a name/value combo and then display it in a table. I really like displaying it like this (as opposed to using something like UDTypography) as I have a column with the “name” and a consistent spacing to the column with the “value”.

An example of my code is this:

New-UDTable -Id "PMDate" -Title "Project Time Frames" -Headers @(" ", " ") -Content {
					$tableDate = [ordered]@{
						'Proposed Date' = $PMInfo.PMProposedDate
						'Received Proposal from vendor' = $PMInfo.PMReceivedProposalDate
						'Accepted Proposal' = $PMInfo.PMAcceptedProposalDate
						'Project Completed' = $PMInfo.PMCompletedDate
						'Project Fiscal Year' = $PMInfo.FiscalYear
						'Project Quarter' = $PMInfo.Quarter
					}
					$TableDate.GetEnumerator() | Out-UDTableData -Property @("Name", "Value")

					
				} #END UDTable ContactInfo

What might be the best way to replicate something like this in v3 dashboards? While I could do it as a new table, I can’t use the existing hashtable. Ultimately, I want a similar layout (as I actually have used this a lot in my various dashboards), but also am willing to put in the work to use the best display method in v3.

Any ideas for me on this?

You should be able to do this.

					$tableDate = [ordered]@{
						'Proposed Date' = $PMInfo.PMProposedDate
						'Received Proposal from vendor' = $PMInfo.PMReceivedProposalDate
						'Accepted Proposal' = $PMInfo.PMAcceptedProposalDate
						'Project Completed' = $PMInfo.PMCompletedDate
						'Project Fiscal Year' = $PMInfo.FiscalYear
						'Project Quarter' = $PMInfo.Quarter
					}
					$Data = $TableDate.GetEnumerator()
New-UDTable -Id "PMDate" -Title "Project Time Frames" -Data $Data -Columns @(
    New-UDTableColumn -Property Name -Title ""
    New-UDTableColumn -Property Value -Title ""
)

We also still support loading it dynamically, which is what is happening in the v2 table.

Hmm, if I can get that to work, that would be great, but this is what I get with it:

I’ll also add that some of my values are null, so I don’t know if this will cause a problem.

Try defining your variables as a string

.ToString()

I found that if my values were null, they wouldn’t render in the table unless they were defined as a string.

Thanks. I’ll try that, although I do see I have the same output even if there is a value for everything, as well.

The enumerator is kind of weird and Idk why I have to do this but this works.

New-UDDashboard -Title "Hello, World!" -Content {
	$tableDate = [ordered]@{
						'Proposed Date' = 'test'
						'Received Proposal from vendor' = '$PMInfo.PMReceivedProposalDate'
						'Accepted Proposal' = '$PMInfo.PMAcceptedProposalDate'
						'Project Completed' = '$PMInfo.PMCompletedDate'
						'Project Fiscal Year' = '$PMInfo.FiscalYear'
						'Project Quarter' = '$PMInfo.Quarter'
					}
					 $Data = ,@($TableDate.GetEnumerator())
New-UDTable -Id "PMDate" -Title "Project Time Frames" -Data $Data[0] -Columns @(
    New-UDTableColumn -Property Name -Title ""
    New-UDTableColumn -Property Value -Title ""
)
}

Thanks so much! Yeah, it is really weird how that works, but it definitely fixed the issue.