Server Side Tables in 2.6.1 Issue

Server Side version of the table worked in 2.5.4.
In 2.6.1, it displays the loading bar indefinitely.
Code below has local and server side versions. The local works fine.

$DashBoardPages += New-UDPage -Name ‘CompareInstances’ -LoadNavigation $CustomerNavigation -Content {

if ($report_id -le 0) { Invoke-UDRedirect -Url '/Customers' }

New-UDPaper -Children { New-UDCard -Text $report_id }

$CatList = Invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql "select * from categories"

$chkboxes = @()

foreach ($cat in $CatList.Category) {

    $chkboxes += New-UDCheckBox -Id "ChkBoxInst$Cat" -Label $Cat -OnChange { Sync-UDElement -ID IntCompDynamic } -Checked $true

}



New-UDPaper -Children { $chkboxes } -Elevation 2

New-UDRadioGroup -Id CompOption -Label "Option" -Value 'ShowDiff'  -Content {

    New-UDRow -Columns {

        New-UDColumn -LargeSize 1 -Content {

            New-UDRadio -Label 'Show Differences' -Value 'ShowDiff'        

        }

        New-UDColumn -LargeSize 1 -Content {

            New-UDRadio -Label 'Show All' -Value 'ShowAll'

        }

    }

}    -OnChange { Sync-UDElement -Id IntCompDynamic }

   

New-UDDynamic -Id IntCompDynamic -LoadingComponent { New-UDProgress -Circular } -Content {

    $cheked = @()

    foreach ($cb in $chkboxes) {  

        if ((Get-UDElement -id $cb.Id).Checked) {    

            $cheked += $cb.Label

        }

    }

    if ($cheked) {

        $chkboxfilter = " and category in (''" + ($cheked -join "'',''") + "'')"

    }      

    $fieldClause = "split_part( item,'-##-',1) `"Category`",split_part( item,'-##-',2) `"Section`",split_part( item,'-##-',3) `"Element`","

    $instInClause = "instance  in ("

    $instColClause = ""

   

    $e1InstanceComp_Columns = @(

        New-UDTableColumn -Property Category -Title "Category"  -Width 30 -Sort -Filter -FilterType AutoComplete -Truncate

        New-UDTableColumn -Property Section -Title "Section" -Width 30 -Sort -Filter -FilterType AutoComplete -Truncate

        New-UDTableColumn -Property Element -Title "Element" -Width 60 -Sort -Filter -FilterType AutoComplete -Truncate

    )

    foreach ($instance in $Session:CompareList) {

        $fieldClause += "rtrim(`"$($instance.instancename)`") `"$($instance.instancename)`" ,"

        $instInClause += "''$($instance.instancename)'',"

        $instColClause += "`"$($instance.instancename)`" VARCHAR,"

       

        $e1InstanceComp_Columns += New-UDTableColumn -Property $($instance.instancename) -Title "$($instance.instancename)"  -Width 30 -Truncate

    }

    #Show-UDToast -message $Session:CompareList -persistent

    #Show-UDToast -message $instInClause$SQL -persistent

    $fieldClause = $fieldClause -replace “.$”

    $instInClause = $instInClause -replace “.$”

    $instInClause = $instInClause + ") "

    $instColClause = $instColClause -replace “.$”

    $instColClause = $instColClause + ') '

   

    $diffWhereClause = "category||''-##-''||section||''-##-''||element in ( select  item from (select  distinct  on (`"value`") value ,category||''-##-''||section||''-##-''||element as item,count(*) from configuration_data where  report_id = $($report_id)  and  $instInClause group by category||''-##-''||section||''-##-''||element,value having  count(*)=1 ) cnt)"

    $OrderBy = $TableData.orderBy.field

        if ($OrderBy -eq $null) {

            $OrderBy = "split_part( item,'-##-',1) ,split_part( item,'-##-',2) ,split_part( item,'-##-',3)"

        }

        $OrderDirection = $TableData.OrderDirection

        if ($OrderDirection -eq $null) {

            $OrderDirection = 'asc'

        }

        $Where = ""

    if ((Get-UDElement -Id CompOption).Value -eq 'ShowDiff' ) {

        $SQL = "select $fieldClause from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data  WHERE  report_id = $($report_id) $chkboxfilter and $Where  $instInClause and  $diffWhereClause  order by 1,2')   as final_result(`"item`" TEXT,$instColClause ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY"

       

    }

    else {

        $SQL = "select $fieldClause from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data WHERE   $instInClause $where report_id = $($report_id)  $chkboxfilter order by 1,2')   as final_result(`"item`" TEXT,$instColClause ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY "

       

    }

                   

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

    New-UDTable     -Columns $e1InstanceComp_Columns -Sort -Dense -Filter -paging -PageSize 20   -Data $Data

    New-UDTable     -Columns $e1InstanceComp_Columns -Sort -Dense -Filter -paging -PageSize 20   -loadData {

        $TableData = ConvertFrom-Json $Body

           

        $OrderBy = $TableData.orderBy.field

        if ($OrderBy -eq $null) {

            $OrderBy = "split_part( item,'-##-',1) ,split_part( item,'-##-',2) ,split_part( item,'-##-',3)"

        }

        $OrderDirection = $TableData.OrderDirection

        if ($OrderDirection -eq $null) {

            $OrderDirection = 'asc'

        }



        $Where = ""

        if ($TableData.Filters) {

            $Where = " "

       

            foreach ($filter in $TableData.Filters) {

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

            }

       

        }



        $PageSize = $TableData.PageSize

           

        # Calculate the number of rows to skip

        $Offset = $TableData.Page * $PageSize

        if ((Get-UDElement -Id CompOption).Value -eq 'ShowDiff' ) {

            $SQL = "select $fieldClause from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data  WHERE  report_id = $($report_id) $chkboxfilter and $Where  $instInClause and  $diffWhereClause  order by 1,2')   as final_result(`"item`" TEXT,$instColClause ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY"

            $CountSQL = "select COUNT(*) RowCount from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data WHERE   report_id = $($report_id) $chkboxfilter and $Where  $instInClause and  $diffWhereClause  order by 1,2')   as final_result(`"item`" TEXT,$instColClause "

        }

        else {

            $SQL = "select $fieldClause from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data WHERE   $instInClause $where report_id = $($report_id)  $chkboxfilter order by 1,2')   as final_result(`"item`" TEXT,$instColClause ORDER BY $OrderBy $OrderDirection OFFSET $Offset ROWS FETCH NEXT $PageSize ROWS ONLY "

            $CountSQL = "select COUNT(*) RowCount from crosstab('select category||''-##-''||section||''-##-''||element as `"item`",`"instance`",value from configuration_data WHERE  $instInClause and $where report_id = $($report_id) $chkboxfilter order by 1,2')   as final_result(`"item`" TEXT,$instColClause  "

        }

        #Set-UDClipboard -Data ($CountSQL)

        $Count = invoke-PostgreSqlQuery -ConnectionString $PGConnectionString -Sql $CountSQL

        #Set-UDClipboard -Data ($SQL)

        #Show-UDToast -message ($Count) -persistent

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

       

        $DL = $Data | Format-List | Out-String

        Set-UDClipboard -Data $DL

        Show-UDToast -Persistent -Message $DL

        Show-UDToast -Persistent -Message ($TableData.page | Out-String)

        Show-UDToast -Persistent -Message ($Count | Out-String)

        Show-UDToast -Persistent -Message ($TableData.properties | Out-String)

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

    }  

           

}

}

:wave: @RavenSword - I think the table issue is related to the nested element bug in 2.6.1.

I raised Nested Elements don't render as expected - #4 by LiamPeters which is about nested elements. We also saw issues with tables not loading which I think is the same issue. Adam has posted saying 2.6.2 will shortly be available so try that.

1 Like

2.6.2 is now available: PowerShell Universal 2.6.2

https://ironmansoftware.com/downloads

Let me know if you still have issues.

Working with 2.6.2, but only when I pipe $data into Out-UDTableData, i.e. this works:
$Data | Out-UDTableData -Properties $TableData.properties -Page $TableData.page -TotalCount $Count.RowCount

But using the -Data parm did not.