new-UDDatePicker overwrites $EventData values

Hello,

I would like to get the $EventData.name value from the page Data in the -OnChange of the New-UDDatePicker element but it seems not possible. I understand that the New-DatePicker overwrites the initial $EventData with all the values in it, in its scope by the date picked (which is not the case for all the function such as New-Button and its -Onclick event where i still have acces to my $EventData).

I would like to know if there is a way to do what i’m trying in order to pass theses 2 arguments to my api. thank you !

$pages = @()

$date = Get-Date

$pages += new-UDPage -Name "page" -Content {
        $request = (invoke-WebRequest http://api).Content | ConvertFrom-Json
        $Data = @()
        $count = 0
        $request | ForEach {
                $Data += @{
                    'name' = $_.name  
                    'expired_date' = ($_.AccountExpirationDate).ToString("yyyy-MM-dd")
                    'id' = $count
                }
                $count++
            }
        
        $Columns = @(
            New-UDTableColumn -Property "Prolong" -Title "Prolongation" -OnRender {
                new-UDDatePicker -MinimumDate $date.AddDays(1) -OnChange{
                    show-UDToast -Message "$($EventData.name) enable until $EventData" -Duration 3000
                }
            }

        )

    new-UDTable -Data $Data -Id "table1" -Columns $Columns -Paging -PageSize 5  
} -Url "/api/:data"

New-UDApp  -Pages $pages

Show-UDToast returns the date but not the user name

I’ve tried to play around but seems like there’s no way. The function new-UDDatePicker doesn’t take any parameter so that i can pass the user nor returns any value so that I can get the date the user picked.

$user = $EventData.name
                new-UDDatePicker -MinimumDate $date.AddDays(1) -OnChange{
                    param($user)
                    show-UDToast -Message "$user enabled until $EventData" -Duration 3000
                }

               $date = new-UDDatePicker -MinimumDate $date.AddDays(1) -OnChange{
                   show-UDToast -Message "$user enabled until $EventData" -Duration 3000
               }

I think even with the session or cache it doesn’t work for what i’m trying to do.
If you guys have any ideas, it would be cool. Thank you =)

Hello,

I found how to get the date from the calendar. Juste needed to use Get-UDelement followed by the Id of the calendar.

However I wanted to know also, is there a way to refresh and to be redirected to the same page of the table. Let’s say I activate a user at the second page of my table, i want to refresh and to be redirected to this exact same page of the table to simplify the users. Thank you !