How to do a simple table update in V3?

I’m absolutely struggling to figure out how in V3 to update a table. There are many examples of this in V2, but it seems to be very different in V3. I’m sure it’s quite simple, I just need an example to follow.

Here’s what I have so far. I just need the button to do an update, any update, to the table on the page after the button click.

$Pages += New-UDPage -Name "Testing"  -Content {

    $Session:Data = @(

        @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}

    )

    New-UDContainer {

        New-UDButton -OnClick {

            $Session:Data = @(

                @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}

            )

            Sync-UDElement -iD 'results'

        }

        New-UDTable -Id 'results' -Title "Files" -Data $Session:Data -AutoRefresh

        

    }

}

Try something like this.

 $Session:Data = @(
        @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    )

    New-UDContainer {

        New-UDButton -OnClick {

            $Session:Data = @(

                @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}

            )

            Sync-UDElement -iD 'results'

        }

        New-UDDynamic -AutoRefresh -Id 'results' -Content {
                  New-UDTable -Title "Files" -Data $Session:Data 
        }
        
    }
2 Likes