How to convert UDGrid from V2 to UDTable in V3?

Hi all,

I will upgrade my UniversalDashboard to V3. But how can I convert a UDGrid like these in a UDTable in V3?

 New-UDGrid -Title "Mitarbeiter zur Weiterberechnung hinzufuegen" -PageSize 3 -NoExport -FilterText "Mitarbeitername eingeben" -Id "WeiterKostHinzuID" -Headers @(" ", "Name", "Tochtergesellschaft") -Properties Hinzufuegen, Name, Company -Endpoint {
          $Objects2 = Get-ADUser -Filter {(enabled -eq "true" -and ExtensionAttribute1 -notlike "*")} -Properties Displayname, Company, SamAccountName, ExtensionAttribute1 | Sort-Object name
          $Objects2 | ForEach-Object {
            [PSCustomObject]@{
                  
                  Name = $_.Name
                  Displayname = $_.Displayname
                  SamAccountName = $_.SamAccountName
                  Company = $_.Company
                  
                  
                  Hinzufuegen = New-UDButton -Floating -Icon plus -OnClick {
                            
                    Set-ADUser -Identity "$($_.SamAccountName)" -Add @{extensionAttribute1="berechnen"}    
                    Set-ADUser -Identity "$($_.SamAccountName)" -Add @{extensionAttribute2="AD"}  
                    Show-UDToast -Message "$($_.Name) hinzugefuegt" -Duration 5000
                    Sync-UDElement -Id "WeiterKostID"
                    Sync-UDElement -Id "WeiterKostHinzuID"  
                  
               
                  }
              }
          } | Out-UDGridData

        }

Thanks !!!

Hi, @TiX

There are some great examples here and source code for that page here , hope that helps.

I’d made a new post here - I’m not a developer by any means, but having said that I’m struggling to migrate to v3 big time.

Did you figure this out @TiX?

@mmcdougall not yet :confused:

I am a few steps further, data are displayed and paging is working, but i still have problems with sorting and filtering. I have tried different things, but until now its not working. How do I put in this code correct filtering and sorting?

Can someone help me? Thanks a lot!!

New-UDTable -Title 'AD Computer' -LoadData {
                $TableData = ConvertFrom-Json $Body      
                $PageSize = $TableData.PageSize
                $Offset = $TableData.Page * $PageSize
                $Nxtrow = $offset + 5

                $count = (Get-ADComputer -Filter {(Name -like "NB-*")}).count
                $Data = (Get-ADComputer -Filter {(Name -like "NB-*")} -Properties @("Name", "Description", "IPv4Address", "OperatingSystem"))[$Offset..$Nxtrow] | ForEach-Object {

                    @{ 
                        name = $_.name 
                        description = $_.description
                        ipv4address = $_.ipv4address
                        operatingsystem = $_.operatingsystem
                    }
                } 
                $Data | Out-UDTableData -Page $TableData.page -TotalCount $count -Properties $TableData.properties
            } -Columns @(
                New-UDTableColumn -Property 'Name' -Sort $true -Filter $true
                New-UDTableColumn -Property 'Description' -Sort $true -Filter $true
                New-UDTableColumn -Property 'IPv4Address' -Sort $true -Filter $true
                New-UDTableColumn -Property 'OperatingSystem' -Sort $true -Filter $true
            ) -Sort -Filter

Does somebody has any idea? :confused:

I don’t see any filtering or sorting code in your example code. Can you show what you have tried?

Have you seen this blog post that goes into detail about the sorting and filtering?

1 Like