I am not sure if this is by design or a bug. I am using the following code below but would like to be able to unselect a row after it has been selected. Essentially bringing all rows back to a default unchecked state. Currently when I select a row, my only option is to select another row. Could we make it so the selected row could be unchecked when using -DisableMultiSelect?
$TableData = @(
@{ Id = 1; Name = 'Adam'; number = Get-Random }
@{ Id = 2; Name = 'Tom'; number = Get-Random }
@{ Id = 3; Name = 'Sarah'; number = Get-Random }
)
$Columns = @(
New-UDTableColumn -Property Name -Title 'Name'
New-UDTableColumn -Property number -Title 'Random Number'
)
New-UDTable -Data $TableData -Columns $Columns -RemoveCard -ShowSelection -HideToggleAllRowsSelected -DisableMultiSelectOK, I found a solution. I had to wrap the table in a New-UDDynamic and then check if row was unselected. If it was, then call Sync-UDElement to update the table.
$TableData = @(
@{ Id = 1; Name = 'Adam'; number = Get-Random }
@{ Id = 2; Name = 'Tom'; number = Get-Random }
@{ Id = 3; Name = 'Sarah'; number = Get-Random }
)
$Columns = @(
New-UDTableColumn -Property Name -Title 'Name'
New-UDTableColumn -Property number -Title 'Random Number'
)
New-UDDynamic -Id 'DynamicTableSection' -Content {
New-UDTable -id 'MyTable' -Data $TableData -Columns $Columns -RemoveCard -ShowSelection -HideToggleAllRowsSelected -DisableMultiSelect -OnRowSelection {
if($EventData.Selected) {
$myText = "$($EventData.name)"
}
else {
$myText = "No row selected"
Sync-UDElement 'DynamicTableSection'
}
Set-UDElement -Id "lblOutput" -Properties @{
text = $myText
}
}
}
New-UDTypography -Id "lblOutput" -Text ""