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
}
}
}