Dashboard Server-side tables

Dashboard tables: I have followed instructions and blog articles https://blog.ironmansoftware.com/universal-dashboard-server-side-table/ & https://docs.ironmansoftware.com/dashboard/components/data-display/table to create a table.

I am using Universal Powershell 1.3.1, Powershell 7 and V3 Dashboard.

The code gets ad group members and displays them in a server-side table, however when creating a button within the table, the first page works great but when I go to the next page the button refers to the values of the first page.

For troubleshooting purposes, I have named the button after the user login.

It will be me! But could anyone advise me on where I have gone wrong? If I select 20 rows on a page then it will work only when I move away from page one does it fail!

Code:

New-UDDynamic -Id 'results' -Content {
New-UDTable -Title "Members" -LoadData {
    $TableGroupData = ConvertFrom-Json $Body

    <# $Body will contain
        filters: []
        orderBy: undefined
        orderDirection: ""
        page: 0
        pageSize: 5
        properties: (6) ["Name", "Samaccountname", "Title", "Department", "Telephone", "Action"  ]
        search: ""
        totalCount: 0
    #>


    # Calculate the number of rows to skip - fixes paging issue
    $PageSize = $TableGroupData.PageSize
    $Offset = $TableGroupData.Page * $PageSize
    $Nxtrow = $offset + 5
    
$count = (Get-ADGroupMember $session:PassGroupName).count
$Session:Groupdisplay = (Get-ADGroupMember $session:PassGroupName  -Credential $Cache:DomainCred | get-aduser -Credential $Cache:DomainCred -Properties Displayname, title, Company, Department, telephoneNumber | Select Displayname, title, department, telephoneNumber, SamAccountName)[$Offset..$Nxtrow]| ForEach-Object {
 @{DisplayName = $_.DisplayName
 Samaccountname = $_.samaccountname
 Title = $_.Title
 Department = $_.Department
 telephoneNumber = $_.telephoneNumber
 }
                 }

$Session:Groupdisplay  | Out-UDTableData -TotalCount $count -Page $TableGroupData.page -Properties $TableGroupData.properties }  -Columns @(
    New-UDTableColumn -Property Displayname -Title "Name"
    New-UDTableColumn -Property Samaccountname -Title "User ID"
    New-UDTableColumn -Property Title -Title "Title"
    New-UDTableColumn -Property Department -Title "Department"
    New-UDTableColumn -Property telephoneNumber -Title "Telephone"
    New-UDTableColumn -Property Action -Title "Action" -Render { 
        $Item = $Body | ConvertFrom-Json 
        New-UDButton -Id "btn$($Item.Displayname)" -Text "$($Item.samaccountname)" -OnClick {
            Show-UDToast -Message "Removing user $($Item.displayname)" -Duration 5000
            Remove-ADGroupMember -Credential $Cache:DomainCred -Identity $session:PassGroupName -Members $Item.Samaccountname -Confirm:$false -ErrorAction SilentlyContinue
           Sync-UDElement -iD 'results'
        

            }
}
)
 }
1 Like

This sounds like a bug. I’ll throw it in our backlog to take a look.

I experienced the same thing, my workaround was setting the $_. values to new variables and assign them within the onclick values., I’ll see if I can send you the code later today.

( later today)

$CustomerList | Foreach-Object {

        $tenantid = $_.CustomerId

        $displayName = $_.DisplayName

        [PSCustomObject]@{

            TenantId          = $_.CustomerId

            DisplayName       = $_.DisplayName

            DefaultDomainName = $_.DefaultDomainName

            TamReport         = New-UDButton -Text 'Generate TAMReport' -OnClick {

                Show-UDToast -Message "Generating TAM Report for Customer: $displayName - TenantId: $tenantId" -Duration 3000

                Invoke-UAScript -Id 18 -TamCustomer $TenantId -AppToken $fullAppToken

            }

        } 

}

(I know hardcode script ID here is dealt with, no longer doing that ;))

This is resolved in 1.3.2 as well. It should be out this week.

I’m working on getting familiar with all of these tools. Likely getting a license very soon. However, when working off of your article, I’m running into similar issues as op. Any time I’m paging through data, it does not load new data, but when viewing more rows it will pull that data. The easiest demonstration is showing rows of 11-14 but still seeing 10 rows.

v1.3.2, PS 5.1 & 7.0, v3 Dashboard.

@rossu Did you happen to upgrade from a previous version of PSU? Or is this a fresh install?

I ask because we don’t automatically upgrade dashboards to the latest dashboard framework (although, I think we will add an option in the future to do so). More info on that here: https://docs.ironmansoftware.com/getting-started/upgrading#dashboard-components-and-frameworks

I’ve tried the example on the 1.3.2 version and do not see an issue with paging so I’m wondering if that’s the problem.

It was my issue, I’m assuming that there are reasons why -Sort is not a switch but a boolean. It helps to read through the entire article as well. Obviously not an issue with the version of PSU. Thanks for the quick reply @adam

Cool. Glad it’s working. Those parameters really should be switch parameters so that’s my fault. I’ll throw an issue in our backlog to fix that. It’s probably a breaking change so won’t be addressed to the next major version unless we can get creative.

Hey Adam! Thank’s upgraded to 1.4.2 and works a treat! Thank you :smiley: :+1: