Dynamic UDTableColumns

Hi

I’m defining my table columns at runtime, basically I have a table with columns of ‘services’ however at design time I don’t know that those services are going to be. I’m then trying to render them

foreach ($p in $cpu.services) {
    $cols+=New-UDTableColumn -Property $p -Title $p -IncludeInExport -Render {
         New-UDTypography $eventdata.$p #This will get more complex later.
    }
}
 

This code isnt working though, becuase it doesnt seem that $p is getting exposed to the code inside the Render script block.

is there a better way that I should pass the value through, alternatively is there a way to refer to the value of the current column in the Render block?

Hi,

your code is working for me :wink: