Server Side paging issue

I folled the server side log post, but get odd results…
I’ll get 1 row back most of the time, though its set to 5, and sometimes a few more, the amount is repeatable for a given page…

Code:

New-UDTab -Text “Instances” -Dynamic -Content {

            New-UDTable     -Columns $e1Instance_Columns -Sort  -Filter -paging -loadData {

                $TableData = ConvertFrom-Json $Body

               

                $OrderBy = $TableData.orderBy.field

                if ($OrderBy -eq $null) {

                    $OrderBy = "hostname,instancetype,instancename,toolsrelease"

                }

                $OrderDirection = $TableData.OrderDirection

                if ($OrderDirection -eq $null) {

                    $OrderDirection = 'asc'

                }

                $Where = "WHERE  report_id = $repID"

                if ($TableData.Filters) {

                    $Where = "WHERE "

           

                    foreach ($filter in $TableData.Filters) {

                        $Where += $filter.id + " LIKE '%" + $filter.value + "%' AND "

                    }

           

                    $Where += " report_id = $repID "

                }

                $PageSize = $TableData.PageSize

               

                # Calculate the number of rows to skip

                $Offset = $TableData.Page * $PageSize

                $Count = Invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql "select COUNT(*) RowCount from e1instances $where  "

                $SQL = "select hostname,instancetype,instancename,toolsrelease,componentdescription from e1instances $Where  ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY "

                $CurInstances = Invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql $SQL

                #if ($null -eq $CurInstances  ) { $CurInstances = @(@{Error = 'Data Not Available' }) }

                $CurInstances | Out-UDTableData -Page $TableData.page -TotalCount $Count.RowCount -Properties $TableData.properties  

            }

           

        }

I tried the same code for a differant table and get 6 to 8 rows back instead of 10.

Product: PowerShell Universal
Version: 1.4.6

Hmmm. I don’t see anything obvious. One thing you can try to do is to use Show-UDToast to see the SQL commands that are running. It might give a hint as to where the issue lies.

New-UDTab -Text “Instances” -Dynamic -Content {
            New-UDTable     -Columns $e1Instance_Columns -Sort  -Filter -paging -loadData {
                $TableData = ConvertFrom-Json $Body
                $OrderBy = $TableData.orderBy.field

                if ($OrderBy -eq $null) {
                    $OrderBy = "hostname,instancetype,instancename,toolsrelease"
                }

                $OrderDirection = $TableData.OrderDirection
                if ($OrderDirection -eq $null) {
                    $OrderDirection = 'asc'
                }

                $Where = "WHERE  report_id = $repID"
                if ($TableData.Filters) {
                    $Where = "WHERE "
                    foreach ($filter in $TableData.Filters) {
                        $Where += $filter.id + " LIKE '%" + $filter.value + "%' AND "
                    }
                    $Where += " report_id = $repID "
                }

                $PageSize = $TableData.PageSize

                # Calculate the number of rows to skip
                $Offset = $TableData.Page * $PageSize
                Show-UDToast "select COUNT(*) RowCount from e1instances $where  "
                $Count = Invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql "select COUNT(*) RowCount from e1instances $where  "
                $SQL = "select hostname,instancetype,instancename,toolsrelease,componentdescription from e1instances $Where  ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY "
                Show-UDToast $SQL
                $CurInstances = Invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql $SQL

                $CurInstances | Out-UDTableData -Page $TableData.page -TotalCount $Count.RowCount -Properties $TableData.properties  
            }
        }