Refreshing new-udgrid

Hi all,

So I’ve got 2 grids, which are fed from the same ssh call, with some slightly different regex filtering. This is all working fine, but I’d like the user to be able to hit refresh on any of the grids, this would then trigger an update to the scheduled UD-Endpoint and refresh both UDGrids. Is this possible?

New-UDGrid -Title "Clear Appservers" -AutoRefresh -RefreshInterval 250 -PageSize 50 -Endpoint {
            $cache:appservergrid1 | Out-UDGridData
        }
New-UDGrid -Title " " -DefaultSortColumn 'Last Change' -AutoRefresh -RefreshInterval 250 -PageSize 50 -Endpoint {
            $cache:appservergrid2 | Out-UDGridData
        }

function refresh_appservergrids {
    $cache:clear = get-clearappserver
    $stringData = $cache:clear.appserver -join "`n"

    $cache:appservergrid1 = if ($stringData -match '.+\s+:\s+.+[\s\S]+.+\s+:\s+.+') {
        $matches[0] -replace '\s+:\s+', '=' |
        ConvertFrom-StringData |
        ForEach-Object GetEnumerator
    }
    $cache:appservergrid2 = if ($stringData -match 'PID\s+State[\s\S]+') {
        $matches[0] -split '\n' |
        Where-Object { $_ -match '(?<PID>\d+)\s+(?<State>\S+)\s+(?<Port>\d+)\s+(?<Requested>\d+)\s+(?<Received>\d+)\s+(?<Sent>\d+)\s+(?<Started>\d\S+\s\d{2}:\d{2})\s+(?<LastChange>\d\S+\s\d{2}:\d{2})' } |
        ForEach-Object {
            $matches.Remove(0)
            [PSCustomObject]@{
                PID           = $matches['PID']
                State         = $matches['State']
                Port          = $matches['Port']
                Requested     = $matches['Requested'] -as [Int]
                Received      = $matches['Received'] -as [Int]
                Sent          = $matches['Sent'] -as [Int]
                Started       = Get-Date $matches['Started']
                'Last Change' = Get-Date $matches['LastChange']
            }
        }
    }
}

$Schedule = New-UDEndpointSchedule -Every 5 -Minute
$endpoint = New-UDEndpoint -Schedule $Schedule -Id sql -Endpoint {
    refresh_appservergrids
}

Thanks

Hi @Alc I can’t give you a working example right this second…but I believe you could do this, if you gave your grids the -id parameter and then made a button to sync both of those IDs for the grids with a refresh call to repopulate the data…sorry I havent fully inspected your code, but couldnt see an -id parameter being used on the grids…this is how I would approch this…although the grids do have a refresh button on them and as long as you aint using IE that should work.