Remove selection on DataGrid programmatically

Product: PowerShell Universal
Version: 5.5.4

Hello,

I have a UDDataGrid component with selectable rows. I try to find a way to deselect all selected elements programmatically.

I tried something like this :

Set-UDElement -Id 'DataGrid' -Attributes @{ Selection = $null }
Sync-UDElement -Id 'DataGrid'

It works but the webUi is not well refreshed because my old selected elements are still checked.

Do you guys have any idea ?
Thanks !

Hello,

I have exactly the same issue, I try to empty my variables, my sessions but same the past selection stays…

If anyone has an idea ?

Hey @parzog , do you have any idea about this issue (that seems present since a long time : Refreshing the data in a data grid (Selected Rows remain after sync) - #3 by l.malherbe)?

I haven’t looked at this. Let me cobble together a datagrid and give it a test; I’ll reply back with what I find.

Interestingly, the following button:


        New-UDButton -Text "button" -OnClick { $r = (Get-UDElement -Id "DataGrid").selection; Write-Information "r: $(ConvertTo-Json $r)"; Set-UDElement -Id "DataGrid" -Attributes @{ selection = @("selectedRowId") }; Sync-UDElement -Id "DataGrid"; $r = (Get-UDElement -Id "DataGrid").selection; Write-Information "r: $(ConvertTo-Json $r)"; }

Puts the output in the console showing the updated selection value, but the UI does not respond. This is a possible bug. @adam, anything to add?