This might be a newb question but how do you go about clearing a udgrid? Passing $null or “” | out-udgrid does nothing. clear-udelement doesnt work either. I have the code I am testing with below.
New-UDCard -Title "Target List" -Endpoint{
New-UdGrid -Id "Target" -AutoRefresh -RefreshInterval 1 -Endpoint {
$modlist = @()
$alist = @()
if($session:slist.count -gt 0){
$alist = $session:slist.ToArray() | sort -Unique
$alist | Foreach-Object {
[PSCustomObject]@{
Name = $_.Name
Remove = New-UDButton -Text "Remove" -OnClick {
$session:slist.Clear()
$newlist = $_
$modlist = $alist | ?{$_ -ne $newlist}
$modlist | %{$session:slist.Add($_)}
}
}
} | Out-UDGridData
}else{
$null | Out-UDGridData
}
}
New-UDButton -Text "Clear List" -OnClick {
$session:slist.clear()
}
}
}