New-UDTable not conforming to pagesize set

Hi there, running the latest build (1.5.8) of UD. When using a New-UDTable, the -pagesize parameter doesn’t seem to be working. All records are displayed regardless of the number set. Weirdly, the navigator down the bottom shows the correct page size. In this example, pagesize is set to 10, however all 67 records are displayed on the page. Using the right and left arrows does nothing.

I get the feeling something hasn’t finished processing or isn’t entirely resolved, but the ‘Loading…’ message has gone and all other functionality in the table is working.

Does anyone know how to fix?

Also, if I remove -pagesize, all records are still displayed. Changing the dropdown filter for records per page has no effect.

Are you using the -TotalCount parameter as mentioned here:-

Are you also able to post an example of your code for the table if this suggestion does not fix your issue, then sure those who are using PU will be able to advise more. :slight_smile:

Thanks @psDevUK - already using totalcount and verified that the count is correct.

The code’s going to be pretty difficult to post as it’s very long and will need to be de-identified.

This is the New-UDTable component:

New-UdTable -Title 'Title' -showsearch -pagesize 10 -columns @(...) -loaddata { ...
    $data | Out-UDTableData -Page $ -TotalCount $Data.Count -Properties $

What I have done is comment out all columns and code in loaddata one by one, and still haven’t been able to resolve.

Any further advice would be greatly appreciated.

No problems @mmcdougall I still need to get on and use PU have you tried invoking the variable on the -TotalCount parameter something like:-
I know I had to do this sort of thing to make sure some stuff reads properly if you get me. Probably a typo but you mention $data then you are calling $Data in the parameter set…as mentioned probab a copy paste typo thing but also look into that

Yep @psDevUk definitely tried with and without, the count is returning the correct integer. Spent a while thinking that was the cause.

When this happened in the ‘traditional’ version of Universal Dashboard, it was because an element of the dashboard hadn’t finished loading, and any dynamic elements like buttons in columns would refuse to respond. On this occasion however the dashboard loads and responds exactly as expected however doesn’t conform to the pagesize set, which is causing somewhat of a UX issue, especially when you have 500+ lines.

Ok so if the query takes some time to process I tend to use the Timeout parameter on my SQL query to make sure it has plenty of time to run…also just out of curiosity have you tried putting the data into a $Cache variable name and load the data from cache variable instead of on-the-fly just thinking of other ways…hope this helps…?
Also not seeing you specifying the columns like in the examples on Build Server-Side tables with PowerShell Universal Dashboard
and not seeing the -Sort parameter being used…this may or maynot solve the issue?

I haven’t looked at $Cache but as other tables in my dashboard have the same issue even with minimal amounts of data to load, I don’t think this is going to be the culprit. Do you know of any examples to use this? The table needs to load on demand as the data changes minute to minute, not sure if that approach will still work?

Have also tried -sort and basically every other switch available to no avail.

Thanks for your continued assistance @psDevUK.

Again I am not using PU just yet, but as I do follow @adam on twitter I saw he tweeted this the other day:-

Hoping there will be an example in there you can use, and be like… :eyes: ah I see…

I mean I would have hoped like doing a copy and paste of the example on the linkn in my previous post should render the results you require…

In UD I have used CACHE when needed to from SQL, and you can set the update to say 1 min 5 mins etc…but yeah if all your tables having this…I always use GitHub - sqlcollaborative/Invoke-SqlCmd2: PowerShell module containing Invoke-SqlCmd2 to do my SQL queries…then pass the data from that…not sure what you using for the SQL connection? Assuming you are using SQL…?

Forgot to mention but I did my own table component here:-
Would you give that a go to see if you get the same issue…?

Do you use server side?

Hi @AlonGvili, yep, I use server side with the -loaddata switch. The code is basically an import-module followed by a couple of gets in a foreach, which generates a hashtable to Out-UDTableData.

Swear I saw someone post that they fixed their issue by using a PSCUSTOM OBJECT instead of using a hashtable…

I’ve just tested by adding [PSCustomObject] in front of the existing @{ hashtable with no joy.

Is that post indicating you’d need an array of custom objects? Something like this?

Existing code:

                $data = @{
                    Name      = $_.UserName
                    EmailAddress = $_.UserEmail | Out-String
                    Status         = $_.State | out-string
                    App            = $App.Name

New code:

[array]$data += New-Object PSObject -Property @{Name = $_.UserName}
$data += New-Object PSObject -Property @{EmailAddress = ($_.UserEmail | Out-String)}
$data += New-Object PSObject -Property @{Status = ($_.State | out-string)}
$data += New-Object PSObject -Property @{App = $App.Name}

Try set the data to this
data = @(
Name = _.UserName EmailAddress = .UserEmail | Out-String
Status = $
.State | out-string
App = $App.Name

you need to limit the data set in the code :slight_smile:
with the $Body in the LoadData
The $Body parameter will contain a hashtable the following options:

filters: @()
orderBy: string
orderDirection: string
page: int
pageSize: int
properties: @()
search: string
totalCount: int

so something like this:

New-UdTable -Title ‘Title’ -showsearch -pagesize 10 -columns @(…) -loaddata { …
$skip = $ * $Body.pageSize
$data | select -skip $skip -first $Body.pageSize | Out-UDTableData -Page $ -TotalCount $Data.Count -Properties $

you also need to handle the order by and order direction yourself :slight_smile:

also see this for inspiration: universal-dashboard-documentation/ at e390093dcd5d8d68e7ba58ff1136304c71cf9473 · ironmansoftware/universal-dashboard-documentation (

okey I also see that the link psDevUK send it pretty good :slight_smile: but you do need know how what to look for :smiley: (all the limiting and sorting of the SQL query, maybe you missed that from the link?)
Build Server-Side tables with PowerShell Universal Dashboard (