i have a custom button build for v.2.9.0 before and used to work perfect but trying it with V3 it shows up and everything except properties wont make it to onclick script block.
like data from column like $EvenetData.Name will be null inside onclick {}
my custom button used to use this line in the script
if ($null -ne $OnClick) {
if ($OnClick -is [scriptblock]) {
$OnClick = New-UDEndpoint -Endpoint $OnClick -Id ($Id + "onClick")
}
elseif ($OnClick -isnot [UniversalDashboard.Models.Endpoint]) {
throw "OnClick must be a script block or UDEndpoint"
}
}
hot to modify above for this custom button to work again.
i have posted the .jsx code above and below is the .ps1 script
function New-UDButtonLoader {
param(
[Parameter()]
[string]$Id = ([Guid]::NewGuid()),
[Parameter()]
$Text,
[Parameter()]
[Switch]$isLoading,
[Parameter()]
[UniversalDashboard.Models.FontAwesomeIcons]$Icon,
[Parameter()]
[ValidateSet('left', 'right')]
[String]$IconAlignment = 'left',
[Parameter()]
[object]$onClick,
[Parameter()]
[String]$BackgroundColor,
[Parameter()]
[string]$loaderType,
[Parameter()]
[Switch]$disabled
)
if ($null -ne $OnClick) {
if ($OnClick -is [scriptblock]) {
$OnClick = New-UDEndpoint -Endpoint $OnClick -Id ($Id + "onClick")
}
elseif ($OnClick -isnot [UniversalDashboard.Models.Endpoint]) {
throw "OnClick must be a script block or UDEndpoint"
}
}
if ($PSBoundParameters.ContainsKey("Icon")) {
$IconName = [UniversalDashboard.Models.FontAwesomeIconsExtensions]::GetIconName($Icon)
}
@{
# The AssetID of the main JS File
assetId = $AssetId
# Tell UD this is a plugin
isPlugin = $true
# This ID must be the same as the one used in the JavaScript to register the control with UD
type = "ud-buttonloader"
# An ID is mandatory
id = $Id
# This is where you can put any other properties. They are passed to the React control's props
# The keys are case-sensitive in JS.
text = $Text
icon = $IconName
iconAlignment = $IconAlignment
isLoading = $isLoading
disabled = $disabled.IsPresent
loaderType = $loaderType
onClick = $onClick.Name
background = $BackgroundColor
}
}
@AlonGvili
Just FYI i have tried the Chip element built-in PSU and the same behavior, if you build a table with a chip for every object and tried to use the chip -onclick {} the eventdata.property ex. â$EventData.Nameâ will be null.
@AlonGvili
but what about the event when you click the button i mean the toggleloader and the get status from the api after you click the button so you know the job is done and the button go back to normal?