Blazorise
Blazorise copied to clipboard
Treeview - Expand all nodes in the TreeView by default
Is your feature request related to a problem? Please describe.
It seems that there is no mechanism to expand all nodes in the TreeView
by default
A clear and concise description of what the problem is. Example: I am trying to set the below Treeview
expand but unfortunately, there is no specific property to configure.
Describe the solution you'd like A clear and concise description of what you want to happen. Include any alternative solutions you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Hello,
While a good feature to have.
You might be able to do this currently.
Have you tried adding the Nodes to the ExpandedNodes
collection? Even if its the full collection? My guess is that it can still figure out the correct structure as long as GetChildNodes
and HasChildNodes
are well defined.
Here is a PR for this: https://github.com/Megabit/Blazorise/pull/4116
Hello,
While a good feature to have.
You might be able to do this currently. Have you tried adding the Nodes to the
ExpandedNodes
collection? Even if its the full collection? My guess is that it can still figure out the correct structure as long asGetChildNodes
andHasChildNodes
are well defined.
Yes, I agree it is a useful feature. I checked that but it didn't work.
Hello, While a good feature to have. You might be able to do this currently. Have you tried adding the Nodes to the
ExpandedNodes
collection? Even if its the full collection? My guess is that it can still figure out the correct structure as long asGetChildNodes
andHasChildNodes
are well defined.Yes, I agree it is a useful feature. I checked that but it didn't work.
Hello, I had some treeview code sitting around from helping a customer. So I went and gave it a try since I was kinda sure it would work. It does work, here's an example.
Let me try this way.
Right. Just post your source code if you can if it isn't working for some reason.
By doing this way it worked. The reason why before did not work was because I just loaded and set it to ExpandedNodes
. So I already loaded the items why do we need to loop again for expanding (child nodes)?
Let me tell you the scenarios we have.
- We need to expand all nodes when we load data.
- We want to store data with
IsExpanded
. (In the current implementation we have to store an extra list for expanded nodes). - Sometimes we want to set a specific node depending on the business logic in the backend.
All in all, If we have expanded information besides the node we can fully control of node. We won't need to store a separate list. Loaded data will have that information.
So I already loaded the items why do we need to loop again for expanding (child nodes)?
On my version I was iterating through every node and adding every node's Children
to the expanded Nodes.
I.E: ByModule adds Developer / Test / Settings Which in turn loops again on each node and adds their own children.... Developer adds IDE / Tools, so on...
If you have the IsExpanded
information on your own data. Then it's easy to just add those exact nodes to the ExpandedNodes
collection.
So with this, do you have enough information to make it work as you'd like on your end?
I would prefer to have one collection rather than two but that is fine.
Thanks for the explanation.
Since your approach support this scenario. Should I close this PR? https://github.com/Megabit/Blazorise/pull/4116
Well we'd still appreciate your contribution to Blazorise.
The ExpandAll is a good feature to have. But of course, in the end its up to you.