universal-dashboard
universal-dashboard copied to clipboard
Unable to refresh grid
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)
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