Remove selection on DataGrid programmatically

Remove selection on DataGrid programmatically

avatar
(anonymous user)
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 !

All Comments (4)

avatar

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 ?

avatar

Hey @AnonymousUser , 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)?

avatar

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.

avatar

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 Driscoll, anything to add?