UDDataGrid with ShowPagination and OnSelectionChange


I try to use UDDataGrid with -ShowPagination and -CheckboxSelection, but I can’t figure out how to make it work. It loses the hooks on the checked items after changing the page while they are still counted in the footer. I only have 20 rows in this example:


I also made a UdToast showing eventdata when OnSelectionChange triggered. EventData also contains 40 elements. I am not sure what these elements are, seemingly random numbers, and these numbers are changing.
I mean if I select an element, and change the page back and forth, the hook disappears and I can select it again, it adds a completely different random number and also keeping the old one. This works very differently than the tables, and I have no clue how to make it work.


I use this example:

with some slight modifications:

     $Data =  1..20 | % {
        @{ Name = 'Adam'; Number = Get-Random }
    New-UDDataGrid -LoadRows {  
      $Data | Out-UDDataGridData -Context $EventData
    } -Columns @(
        @{ field = "name"; render = { 
            New-UDButton -Icon (New-UDIcon -Icon User) -OnClick { Show-UDToast $EventData.Name } } 
        @{ field = "number" }
    ) -AutoHeight $true -Pagination -CheckboxSelection -Density compact -PageSize 10 -OnSelectionChange {
        Show-UDToast -Message "Count: $($EventData.count) Items: $EventData" -Duration 4000