UDButton OnClick in UDTable No Longer Working

Hi @adam -

I recently upgraded from UD2.1.3 to 2.12.2. However, the UDtableColumn $eventData passed to an OnClick event is NULL in the latest version - no issue with the previous version. My code is something like below - the SQL_ID is not passed. What changed?

New-UDTableColumn -Property SQL -Title 'SQL' -Render {
                        $sqlID = $EventData.SQL_ID
                        $sid = $EventData.SID

                        New-UDTooltip -TooltipContent {
                            New-UDElement -tag 'div' -Content { "View SQL" } -Attributes @{ style = @{ 'font-size' = '10px'; } }
                        } -Content { 
                            New-UDIconButton -Id "$sid-sql" -Icon (New-UDIcon -Icon Eye -Size sm) -OnClick {
                            
                                $viewSQL = <SELECT * FROM TABLE WHERE SQL_ID = '$sqlID'>
                                Show-UDModal -Content { 
                                    New-UDElement -tag 'p' -Content { 
                                        "$viewSQL" 
                                    } -Attributes @{ style = @{ 'font-size' = '11px'; 'font-family' = 'Consolas'; } }

                                }
                            }
                        }
                    } -Align center

I’m unaware of any issues with this version and table rendering. Can you please verify the $EventData is null by trying:

Show-UDToast ($EventData | ConvertTo-Json) 

I just want to make sure that it’s not a null property. I just went through the commit history and am not seeing any changes to this particular functionality so I’m not quite sure yet what has changed.

@adam

I have tested this before posting - I have 2 UDtoast, one after column render and one inside button onClick event, the former shows eventData value while the latter is null regardless how I set the variables.

FYI, this is a new server we are migrating to, and I dont see any other issue except this.

Very strange. Can you try this example table? It’s working for me so I want to see if that’s the case for you as well.

New-UDDashboard -Content {
    $Data = @(
        @{Dessert = 'Frozen yoghurt'; Calories = 1; Fat = 6.0; Carbs = 24; Protein = 4.0 }
        @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
        @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
        @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
        @{Dessert = 'Gingerbread'; Calories = 200; Fat = 6.0; Carbs = 24; Protein = 4.0 }
    ) 

    $Columns = @(
        New-UDTableColumn -Property Dessert -Title Dessert -Render { 
             New-UDIconButton -Icon (New-UDIcon -Icon Eye -Size sm) -OnClick { Show-UDToast -Message $EventData.Dessert } 
        }
        New-UDTableColumn -Property Calories -Title Calories 
        New-UDTableColumn -Property Fat -Title Fat 
        New-UDTableColumn -Property Carbs -Title Carbs 
        New-UDTableColumn -Property Protein -Title Protein 
    )

    New-UDTable -Data $Data -Columns $Columns -Sort -Export
}

The eventData is null.

Hi @adam

Any idea where else to look at? I’m lost of ideas, tried every possible solution - redeployed PSU etc.

Looking at the test script that he gave you, I think it was going to fail, $EventData isn’t defined in the script he asked you to try. Change it to $Data and see if it shows then?

I see what the problem is. We need to merge a fix back into 2.x. I’ll get that done today. The problem is actually with New-UDIconButton. If you use New-UDButton, i can work around it for now.

Thanks, @adam. Let me know once it’s released.

This has been released as 2.12.3.

Hi @adam. Thank you! It solved for UDIconButton.

However, this issue also affecting UDchip onClick event - null value. Can you check this too please.

New-UDTableColumn -Property Dessert -Title Dessert -Render { 
             New-UDChip -Label 'Click me' -Variant outlined -OnClick { Show-UDToast -Message $EventData.Dessert } 
        }
1 Like