EDIT2:
I omitted the line that updates the UI "urrentNode.set_checked(checked);", and it run amazingly fast. Apparently this is the reason of that performance bottleneck, what do you guys suggest?
Hello SO,
In short, I'm dealing with Telerik's RadTreeView, and I want enable checking all the child nodes if the user checked the parent node. Simple enough! OK here's my code that handles OnClientNodeChecked event of the TreeView:
function UpdateAllChildren(nodes, checked) {
var i;
for (i = 0; i < nodes.get_count(); i++) {
var currentNode = nodes.getNode(i);
currentNode.set_checked(checked);
if (currentNode.get_nodes().get_count() > 0) {
UpdateAllChildren(currentNode.get_nodes(), checked);
}
}
}
function ClientNodeChecked(sender, eventArgs) {
var node = eventArgs.get_node();
UpdateAllChildren(node.get_nodes(), node.get_checked());
}
And here's the TreeView's markup:
<telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True" OnClientNodeChecked="ClientNodeChecked"></telerik:RadTreeView>
The tree contains quite a lot of nodes, and this is causing my targeted browser (ehm, that's IE7) to really slow down while running it. Furthermore IE7 displays an error message asking me to stop the page from running scripts as it's might make my computer not responsive (yeah, scary enough). So what do you guys propose to optimize this code?
EDIT: Runs pretty fast in firefox and chrome of course. Needles to say, hah?
Thanks in advance