Hey everyone - Implementing UDTreeNode and I notice when I get to the end of my “tree” and click the node it continues to expand the previous values…
Am i doing something wrong?
New-UDTreeView -ActiveBackgroundColor ‘#DFE8E4’ -Node $(New-UDTreeNode -Name ‘View Groups’ -Id ‘view-delegations’ -Icon search_plus) -OnNodeClicked {
foreach ($group in $($_.CustomerGroupObjects | ConvertFrom-Json)) {
New-UDTreeNode -Name $($group.GroupName) -Id $($group.GroupId) -Icon folder
}
}
And what happens is this (see below) where I only want the first 4 Tree Nodes… it seems to be wrapping the foreach…
example of folder view, i hope it will help you
New-UDTreeView -Node (
New-UDTreeNode -Name "Antd" -Children {
Get-ChildItem -Path "$PSScriptRoot\UniversalDashboard.Antd" | % {
$Current = $_
if ($Current.PSIsContainer) {
New-UDTreeNode -Name $Current.Name -Icon folder -Children {
Get-ChildItem -Path $Current.FullName -File | % {
# $icon = (Set-Icon -Extension $_.Extension)
if($_.Extension -eq '.ps1'){New-UDTreeNode -Name $_.Name -Icon terminal}
if($_.Extension -eq '.psd1'){New-UDTreeNode -Name $_.Name -Icon terminal}
if($_.Extension -eq '.psm1'){New-UDTreeNode -Name $_.Name -Icon terminal}
if($_.Extension -eq '.jsx'){New-UDTreeNode -Name $_.Name -Icon react}
if($_.Extension -eq '.js'){New-UDTreeNode -Name $_.Name -Icon js}
if($_.Extension -eq '.md'){New-UDTreeNode -Name $_.Name -Icon markdown}
}
}
}
}
}
)
3 Likes
yup that did the trick - I realized after looking at your example I was using the OnNodeClick instead of Children.
Working as expected now.
Thanks!
2 Likes