5.6.0 nightly user here
Back on v4 I had a dashboard with a New-UDTable, full of data with ShowSelection enabled.
I had a button in the ToolbarContent of my table, that when the user either selected individual items, or all of them, you could click the button which would popup a modal and allow you to make ‘changes’ to all items (writes back to sql, depending on form input in the modal for all items selected in the table).
It seems that when I try to replicate this functionality on v5, unless I’m missing something, if I only use the select all checkbox on the top of the table, the ‘SelectedRows’ rows propery is completely empty when i do Get-UDElement -Id “tableID”. Though based on how this used to function, SelectedRows would have been populated with all items.
I couldnt see any other properties on the table element to identify select all had been used.
Am I doing something wrong or is this a bug?
Possibly for now as a workaround, I could potentially use the -OnRowSelection param instead to update a $Session variable and then use that variable on my toolbar button, but it would be nice if the previous method worked.
Any ideas?
Seems it works fine when I use -Data, but if i’m using server side and use -LoadData it stops working.
Here’s a code example for when it’s not working:
$TestData = {
$Data = @(
@{Dessert = 'Frozen yoghurt'; Calories = 159; 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 = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)
$TotalCount = 5
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
}
$Columns = @(
New-UDTableColumn -Property Dessert -Title "A 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
)
$TableSplat = @{
id = "TestTable"
LoadRows = $TestData
Columns = $Columns
ShowSelection = $True
}
New-UDTable @TableSplat -ToolbarContent {
New-UDButton -Text "Test Select All" -OnClick {
$SelectedRows = Get-UDElement -Id "TestTable" -Property "SelectedRows"
Show-UDToast -Message "selection: $(($SelectedRows | MEasure).count)" -duration 3000
}
}
The odd thing is that this seems to work in v4.
Confusingly, if you select say, 3 rows first, but then change your mind and select all. The ‘SelectedRows’ property still contains 3 selected rows only.
Raised as a bug here: Table ‘SelectAll’ Server-side issues · Issue #4916 · ironmansoftware/powershell-universal