How to disable UDButton in UDTable Column based on property of row data?

The data bound to the row has a boolean property called hasLicense . I would like the button to be disabled if that property is true. My current workaround is that I simply don’t add the button if the property is true. But this makes the rows that don’t have the button have less height that the rows that have the button, which just doesn’t look nice.

                    New-UDTableColumn -Property hasLicense -Title " " -Sort $false -Render {
                            if(!$EventData.hasLicense)
                            {
                                New-UDButton -Id "btn$($EventData.id)" -Text "add to $serialNumber" -OnClick {
                                    Show-UDToast -Message ($EventData | ConvertTo-JSON)
                                    Show-UDToast -Message "Entitlement deleted." -BackgroundColor Green -MessageColor white
                                    Sync-UDElement -Id 'entitlement-region'
                                }
                            }
                        }
Product: PowerShell Universal
Version: 1.5.4

I’m surprised we missed the disabled property for that component. I’ll get that added to our backlog. Should be easy to enable it.

Thanks, Adam. I would also like to mention that the disable switch parameter in New-UDIconButton doesn’t actually appear to work. I attempted to use this in place of New-UDButton and saw no difference visually between the enabled icon buttons and the disabled icon buttons.

1 Like