Depending on the input data, alter the row's style

This code retrieves all of the users that are currently active from list of servers (using API) and displays them in the table.

Here is the code:

New-UDApp -Title 'TEST' -Content   {
    New-UDDynamic -Id 'tabel' -AutoRefresh -AutoRefreshInterval 5 -Content   {
        $data = Invoke-RestMethod -Uri http://xxx/Users -Method GET
        $Columns = @(
        New-UDTableColumn -Property PSComputerName -Title PSComputerName    -IncludeInSearch -DefaultSortColumn
        New-UDTableColumn -Property USERNAME -Title USERNAME  -IncludeInSearch -DefaultSortColumn
        New-UDTableColumn -Property ID -Title ID
        New-UDTableColumn -Property STATE  -Title STATE
        New-UDTableColumn -Property IdleTime  -Title IdleTime
        New-UDTableColumn -Property LogonTime  -Title LogonTime
   New-UDTable -Id "tabel" -Title "Active users" -Columns $Columns -data  $data -Size small -ShowSearch

Sample of output data:

PSComputerName USERNAME ID STATE IdleTime LogonTime
Servername User 19 Disc 2:45 13.03.2024 18.00
Servername User 2 20 Active 2:45 14.03.2024 11.00
  1. How can I mark all of the results with the STATE “Disc” as a gray background (make a different style) and the results with the green background if the logonTime duration is -1 hour?

  2. The table is now displayed in fullscreen mode. How do I arrange this in a small window? The table continued to display in fullscreen even after I put it in the UD-card.

Looking forward to the answers :blush: Thank you.

Product: PowerShell Universal
Version: 4.2.13

my goto for organising stuff is Grids and columns

New-UDGrid -Container -Content {
  New-UDRow -Columns {
      New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
          New-UDPaper -Content { "1" } -Elevation 2
      New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
          New-UDPaper -Content { "2" } -Elevation 2

Grid | v4 | PowerShell Universal

The screen is divided into 12 chunks. so it can fit 2 columns of size 6 fx
ExtraLargeSize, LargeSize, MediumSize, SmallSize and ExtraSmallSize is based on the current display area width. A typical PC widescreen would be ExtraLargeSize and as you make the browser window smaller it will shift to the next lower size.

1 Like

Yes, this will organize better. Thank you PorreKaj

Any tips on question 1 ?

Solution for the QA 1

New-UDTableColumn -Property STATE  -Title STATE -OnRender {
                            if ($EventData.STATE -eq 'DISC') {
                                New-UDParagraph -Text $EventData.STATE -Color 'red'
                            } else {