Issues with treeviews

Product: PowerShell Universal
Version: 3.7.14

I’m attempting to replicate something similar to this:
image

The idea being to give users a way to view virtual machine snapshots, select a snapshot, and then action on that snapshot.
I’ve got no problems building the tree view from the checkpoint data.

The problems I’ve encoutered are:

  1. with new-udtreeview: -onnodeclicked seems to override -expanded:$true. I I create the tree view with just ‘-expanded’ then as desired it is displayed fully expanded, however if I then add ‘onnodeclicked’ so that I can get the ID of the selected node and operate on it, the tree no longer displays fully expanded, each node has to be manually expanded. I’ve foind I can sort of work around this by setting -expanded:$true on each node as it is added to the tree.
  2. with -onnodeclicked: doesn’t seem to be called at all if the node being clicked is created with the -leaf:$true value. This seems like a bug, people should be able to click/select leaf nodes just like they can other nodes.
  3. I can’t seem to figure out how to get/set the attributes of the nodes or the tree, or perhaps I’m setting them but they don’t render properly? I can use ‘get-udElement’ to get the tree view (but not a specific node). When I inspect the values returned I can see that ‘expanded=$true’ is listed, even though the view on the screen is not expanded…calling ‘sync-udelement’ doesn’t seem to cause the view to update and become expanded either.

As a side note I did try upgrading to version 3.8.3, however the performance of my dashboards went way down (taking a very long time to render dynamic components) post upgrade so I rolled back to 3.7.14…if any of the findings above are addressed already in 3.8.3 please forgive me.

The slowness in the dashboard dynamics was resolved in 3.8.4.

As for the other issues:

  1. I can reproduce this. It seems like we need to fix this internally.
  2. I can also reproduce this. The problem is that we are only triggering on nodes as they expand and not the actual node click event. There isn’t a work around for this and is a bug.
  3. It may be possible to do somehow call the *-UDElement commands to update the tree view, but based on what I’m seeing, it may not work as expected. I think what we need to do is implement support for targeting nodes directly with the *-UDElement cmdlets; which is currently not possible.

I’ve opened a catch-all issue to address these issues in our next release.

Thanks, added a comment to the github issue with a couple more requests/ideas that are enhancments rather than bugs. Looking forward to the next release!

I found a couple of new bugs in 3.8.8 on tree views, I created issues in github
Event ID returned on click is not correct:

-Expanded on new-udtreeview doesn’t work as expected:

Additionally is there a way to set the ‘style’ of a node at creation time? Using the example code you’ve provided I can set the background or text style of a node as a result of a button click or other user action, but I haven’t found a way to set it at creation time so that the tree highlights specific nodes without the user having to click something. New-UDTreeNode doesn’t seem to support the -style argument.

1 Like