U4-3249 - Hiding nodes in content tree not working

Created by Marcel van Helmont 26 Oct 2013, 09:17:44 Updated by Marcel van Helmont 26 Oct 2013, 10:08:14

When i want to hide a node in the content tree with the new TreeNodesRendering event i get a error: Collection was modified; enumeration operation may not execute.

i use this code:

private void ContentTreeController_TreeNodesRendering(TreeController sender, TreeNodesRenderingEventArgs e) { foreach (TreeNode item in e.Nodes) { if (item.NodeId == "1067") { e.Nodes.Remove(item); } } }

Comments

Marcel van Helmont 26 Oct 2013, 10:06:43

Oh what I feel stupid, of course you can remove anything from the list as you walk through it.

Solution: private void ContentTreeController_TreeNodesRendering(TreeController sender, TreeNodesRenderingEventArgs e) { e.Nodes.RemoveAll(s => s.NodeId == "1067"); }


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Inline code

Affected versions: 7.0.0

Due in version:

Sprint:

Story Points:

Cycle: