Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Unable to refresh grid #1620

Open
b17u53r opened this issue Apr 21, 2020 · 1 comment
Open

Unable to refresh grid #1620

b17u53r opened this issue Apr 21, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@b17u53r
Copy link

b17u53r commented Apr 21, 2020

I have a function that runs some queries on a database and returns the data on a grid.
When I try to run a different query that includes a different set of columns, then the grid does not refresh. I am unable to refresh the grid without manually refreshing the page.

This does not happen on the UDChart component.

Here is an example of the function:

Get-Report -Date "Last Year" -ReportType "Report 1" returns -> Cat | Number

Cat Number
Cat 549

Get-Report -Date "Last Year" -ReportType "Report 2" Should return -> Cat2 | Number

On the grid:

Cat Number
5436

The Grid refreshes only the data that had previously populated. If I refresh the page then data is displayed correctly.

To Reproduce

Run a function that returns a pscustomobject with two or more properties and send them to a grid. Then run the function again but this time the function should return a pscustomobject with different properties.

Expected behavior

The grid should refresh automatically.

Screenshots

https://imgur.com/a/sPaWStC

Script Sample

       New-UDInput -Title " " -Id "Form" -Content {
            New-UDInputField -Type select -Name "Period"      -Values @($Period)
            New-UDInputField -Type select -Name 'ReportType'  -Values @($ReportType)
            New-UDInputField -Type select -Name 'Departments' -Values @($Departments)
        } -Endpoint {
            param($Period, $ReportType, $Departments)
                $creds = @{
                    TypeName     = 'System.Management.Automation.PSCredential'
                    ArgumentList = "user", $Password
                }
                $params = @{
                    Server      = 'xxx.xxx.xxx.xxx'
                    Database    = 'db'
                    Period      = $Period
                    ReportType  = $ReportType
                    UserName    = 'user'
                    Credentials = New-Object @creds
                }
                $Session:Results     = Get-Report @params
                Sync-UDElement -Id "PieChart"
                Sync-UDElement -Id "ResultGrid"
        } -ArgumentList $Period, $ReportType, $Departments
$gridparams = @{
                        Id = "ResultGrid"
                        DefaultSortColumn = 'Issues'
                        DefaultSortDescending = $true
                        NoExport = $true
                        Title = 'Results'
                        AutoRefresh = $true
                        RefreshInterval = 1
                        }
                New-UDGrid @gridparams -Endpoint {
                     if ("Dep" -eq $Session:Departments -and $Session:ReportType -eq "Cat1") {
                        $Session:Results | Select-Object 'Cat', 'Number' |
                        Out-UDGridData
                    }
                     if ("Dep" -eq $Session:Departments -and $Session:ReportType -eq "Cat2") {
                        $Session:Results | Select-Object 'Cat2', 'Number' |
                        Out-UDGridData
                    }
                }
....

Version Information

  • Windows 10 Version 1909 18363.778
  • PowerShell 5.1
  • Universal Dashboard 2.9
  • UD Hosting Method: (Powershell)
@b17u53r b17u53r added the bug Something isn't working label Apr 21, 2020
@adamdriscoll
Copy link
Member

This issue has been mentioned on Ironman Software Forums. There might be relevant details there:

https://forums.universaldashboard.io/t/unable-to-refresh-data/2541/11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants