Do we have UDGrid row on change event?


I am creating a Grid inside a Collapsible and each row in the grid has elements like switch, select etc. when i change any of the details in values/columns data in row i have event fired and i want to get the entire row data for me to read all elements values and update by backend.

 Any help is appreciated.

Code for Grid Data
Name = $alert.Name
Enabled = if($alert.Enabled) {New-UDSwitch -id “Enabled” -OnText “true” -OffText “false” -On -OnChange{ UpdateMetricAlert -changedData $EventData -metricAlert $alert }}
else {New-UDSwitch -OnText “true” -OffText “false” -OnChange { UpdateMetricAlert -changedData $EventData -metricAlert $alert}};

                        Severity = New-UDSelect -id "Severity" -Option { @(0,1,2,3,4) | foreach {
                                                            if($_ -eq $alert.Severity){ New-UDSelectOption  -Name "$_ minutes" -Value "$_ minutes" -Selected}
                                                            else {New-UDSelectOption -Name "$_ minutes" -Value "$_ minutes"}}
                                                        } -OnChange {UpdateMetricAlert -changedData $EventData -metricAlert $alert};
                        EvaluationFrequency = New-UDSelect -id "EvaluationFrequency" -Option { @(1,5,15,30,60) | foreach {
                                                            if([double]$_ -eq $alert.EvaluationFrequency.TotalMinutes){ New-UDSelectOption  -Name "$_ minutes" -Value "$_ minutes" -Selected}
                                                            else {New-UDSelectOption -Name "$_ minutes" -Value "$_ minutes"}}
                                                        } -OnChange {UpdateMetricAlert -changedData $EventData -metricAlert $alert};
                        WindowSize = New-UDSelect -Id "windowSize" -Option { 
                                                    @(1,5,15,30,60,360,720,1440) | foreach {
                                                        if([double]$_ -eq $alert.WindowSize.TotalMinutes){ 
                                                            if([double]$_ -lt 60){New-UDSelectOption  -Name "$_ minutes" -Value "$_ minutes"  -Selected}
                                                                $hours = [TimeSpan]::FromMinutes($_).TotalHours
                                                                New-UDSelectOption  -Name "$hours hours" -Value "$hours hours" -Selected}}
                                                            $hours = [TimeSpan]::FromMinutes($_).TotalHours
                                                            if([double]$_ -lt 60){New-UDSelectOption  -Name "$_ minutes" -Value "$_ minutes"}
                                                            else{New-UDSelectOption  -Name "$hours hours" -Value "$hours hours"}
                                                        }}} -OnChange {UpdateMetricAlert -changedData $EventData -metricAlert $alert};
                      ResourceId = New-UDElement -id "AlertID" -Tag div -Content{ $alert.Id} -Attributes @{"style"= @{'font-size' = "9px"}};  


@Sriramiyangar welcome to the UD forum

  1. store your grid data in a $Cache: variable
  2. define the id of the grid + use the endpoint instead of the content
  3. update the $Cache: variable data in your actions
  4. use sync-udelemend -id to update the grid element

Hope this will help you out

Sorry wrong answer to your question … :confused:

Maybe someone has the right answer as I havent had that need … But good point @Sriramiyangar

Thank you @augustin.ziegler for the response, i am looking to get data of the resource id fieled so that i can update the changes made base don the ID. Even if we do not have a row change, i am fine if i get to know a way to read data of entire row.

I have firgured out an alternate way of adding New-UDInput inside of grid to get the job done

Hey @Sriramiyangar, can you post sample code that resolved your issue? running into something similar… thanks.

Here you go. I have added an additional edit button to captue the row’s data

foreach ($alert in $filteredAlerts) {



                Name          = $alert.Name;

                ResourceGroup = $alert.ResourceGroup;

                Enabled       = $alert.Enabled.ToString();

                Severity      = $alert.Severity;

                Frequency     = $alert.EvaluationFrequency.TotalMinutes;

                WindowSize    = $alert.WindowSize.TotalMinutes;

                Edit          = New-UDElement -Tag div -Endpoint { New-UDButton -Icon edit -Flat -OnClick {

                        Show-UDModal -Content {

                            New-UDInput -SubmitText "Save" -Content {

                                New-UDInputField -Type 'textarea' -Name Name -DefaultValue $alert.Name

                                New-UDInputField -Type 'textbox' -Name ResourceGroup -Placeholder 'ResourceGroup' -DefaultValue $alert.ResourceGroup

                                New-UDInputField -Type 'select' -Name Enabled -Placeholder 'Enabled' -Values @('True', 'False') -DefaultValue $alert.Enabled.ToString()

                                New-UDInputField -Type 'select' -Name Severity -Placeholder 'Severity' -Values @(0, 1, 2, 3, 4) -DefaultValue $alert.Severity

                                New-UDInputField -Type 'select' -Name Frequency -Placeholder 'Frequency (Minutes)' -Values @(1, 5, 15, 30, 60) -DefaultValue $alert.EvaluationFrequency.TotalMinutes

                                New-UDInputField -Type 'select' -Name Window -Placeholder 'Window (Minutes)' -Values @(1, 5, 15, 30, 60, 360, 720, 1440) -DefaultValue $alert.WindowSize.TotalMinutes

                            } -Endpoint {

                                param($Name, $ResourceGroup, $Enabled, $Severity, $Frequency, $Window)

                                New-UDInputAction -Toast "Alert Modified !!! $Name,$ResourceGroup,$Enabled, $Severity, $Frequency, $Window" -Duration 2000

                                $changedData = [pscustomobject]@{ 

                                    Name          = $Name;

                                    ResourceGroup = $ResourceGroup; 

                                    Enabled       = $Enabled; 

                                    Severity      = $Severity; 

                                    Frequency     = $Frequency; 

                                    Window        = $Window 



                                $alreadyAddedData = $Session:editedMetricAlerts | Where-Object { $_.Name -eq $Name }                            

                                if (!$alreadyAddedData) {



                                else { $alreadyAddedData = $changedData } 





                }-ArgumentList $alert




My Grid:

1 Like

Thanks @Sriramiyangar this was super helpful, digging the edit button with modal :wink: