Missing data when using New-UDTableColumn -Render

I am trying to format the style of some data in a table. When I pass the data to the column without calling -Render, the data shows up. When use -Render on that same data, I am missing data. I believe there is a bug with rendering strings (if string starts with a digit greater than 0) or other data types such as System.Double, System.Int32 and System.Int64.

Here is a basic table and a screenshot of my output:

$Columns = @(

New-UDTableColumn -Property Name -Title 'Display Name' -Render {

    if($EventData.Rate -gt 13.00){

        New-UDStyle -Style 'background-color: lightblue;' -Content {$EventData.Name}

    }

    else{

        $EventData.Name

    }        

}

New-UDTableColumn -Property ID -Title 'Employee ID (unrendered)'

New-UDTableColumn -Property ID2 -Title 'Employee ID' -Render {

    if($EventData.Rate -gt 13.00){

        New-UDStyle -Style 'background-color: lightblue;' -Content {$EventData.ID}

    }

    else{

        $EventData.ID

    }        

}

New-UDTableColumn -Property Rate -Title 'Rate'

<#

New-UDTableColumn -Property Rate -Title 'Rate' -Render {

    if($EventData.Rate -gt 13.00){

        New-UDStyle -Style 'background-color: lightblue; font-weight: bold;' -Content {$EventData.Rate}

    }

    else{

        $EventData.Rate

    }    

} #>

)

$Data = @(

@{Name = 'Spiderman'; ID = '1234567'; ID2 = '1234567'; Rate=12.50}

@{Name = 'Thor'; ID ='0123456'; ID2 ='0123456'; Rate=15.00}

@{Name = 'Black Widow'; ID = '9876543'; ID2 = '9876543'; Rate=17.50}

@{Name = 'Hulk'; ID = '5671234'; ID2 = '5671234'; Rate=9.25}

)

New-UDTable -Data $Data -Columns $Columns

Product: PowerShell Universal
Version: 2.7.4

Hey @jdmuetzel

I was able to get it to display all data by adding New-UDTypography to the -Content block of the style.

$Data = @(
    @{Name = 'Spiderman'; ID = '1234567'; ID2 = '1234567'; Rate=12.50}
    @{Name = 'Thor'; ID ='0123456'; ID2 ='0123456'; Rate=15.00}
    @{Name = 'Black Widow'; ID = '9876543'; ID2 = '9876543'; Rate=17.50}
    @{Name = 'Hulk'; ID = '5671234'; ID2 = '5671234'; Rate=9.25}
)
$Columns = @(
    New-UDTableColumn -Property Name -Title 'Display Name' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDStyle -Style 'background-color: lightblue;' -Content {New-UDTypography -Text $EventData.Name}
        }
        else {
            New-UDTypography -Text $EventData.Name
        }        
    }
    New-UDTableColumn -Property ID -Title 'Employee ID (unrendered)'
    New-UDTableColumn -Property ID2 -Title 'Employee ID' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDStyle -Style 'background-color: lightblue;' -Content {New-UDTypography -Text $EventData.ID2}
        }
        else {
            New-UDTypography -Text $EventData.ID2
        }        
    }
    # New-UDTableColumn -Property Rate -Title 'Rate (unrendered)'
    New-UDTableColumn -Property Rate -Title 'Rate' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDStyle -Style 'background-color: lightblue; font-weight: bold;' -Content {New-UDTypography -Text $EventData.Rate}
        }
        else {
            New-UDTypography -Text $EventData.Rate
        }
    }
)
New-UDTable -Data $Data -Columns $Columns

Just as a side note as well, you do not need to use New-UDStyle each time. You can just utlize New-UDTypography -Style @{}.

$Data = @(
    @{Name = 'Spiderman'; ID = '1234567'; ID2 = '1234567'; Rate=12.50}
    @{Name = 'Thor'; ID ='0123456'; ID2 ='0123456'; Rate=15.00}
    @{Name = 'Black Widow'; ID = '9876543'; ID2 = '9876543'; Rate=17.50}
    @{Name = 'Hulk'; ID = '5671234'; ID2 = '5671234'; Rate=9.25}
)
$Columns = @(
    New-UDTableColumn -Property Name -Title 'Display Name' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDTypography -Text $EventData.Name -Style @{
                'background-color' = 'lightblue'
            }
        }
        else {
            New-UDTypography -Text $EventData.Name
        }        
    }
    New-UDTableColumn -Property ID -Title 'Employee ID (unrendered)'
    New-UDTableColumn -Property ID2 -Title 'Employee ID' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDTypography -Text $EventData.ID2 -Style @{
                'background-color' = 'lightblue'
            }
        }
        else {
            New-UDTypography -Text $EventData.ID2
        }        
    }
    New-UDTableColumn -Property Rate -Title 'Rate' -Render {
        if ($EventData.Rate -gt 13.00) {
            New-UDTypography -Text $EventData.Rate -Style @{
                'background-color' = 'lightblue'
                'font-weight' = 'bold'
            }
        }
        else {
            New-UDTypography -Text $EventData.Rate
        }
    }
)
New-UDTable -Data $Data -Columns $Columns

Thank you!

I also found if I use -Style parameter on New-UDTypography it only styles the text vs using New-UDStyle which styles the entire cell.

I appreciate your help!

1 Like