UDDataGrid with ShowPagination and OnSelectionChange

UDDataGrid with ShowPagination and OnSelectionChange

avatar
(anonymous user)

Hello!

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:

35a1c7efc074b382e06e981d9537dcbab6395853


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.

ee090d49165ac3aebca37dd2f4bab6068b10dcd9


I use this example:

docs.powershelluniversal.com
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
    }```

Thanks,
Imre


ee090d49165ac3aebca37dd2f4bab6068b10dcd9.png

35a1c7efc074b382e06e981d9537dcbab6395853.png

All Comments (0)