This is a migrated thread and some comments may be shown as answers.

Update a node

1 Answer 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
SeRiAlKiL
Top achievements
Rank 1
SeRiAlKiL asked on 11 Sep 2008, 08:59 AM
Hello,

I have a TreeView, wich loads node on demand server side from my database

The treeview is sourrounded by a RadAjaxPanel to avoid visible postbacks

I have added a ContextMenu wich works perfectly

I whould like to add a function to the context menu

When i click that menu voice, i whould like to force the node to collapse, and expand to reload his childs, like when i clicked it for the first time, or at least to collapse it, clear his old nodes and let te user to click again

Actually i am using this function

function ContextMenuClick(sender, args) {  
                    var menuItem = args.get_menuItem();  
                    var treeNode = args.get_node();  
                    var tree = $find("<%= TreePagine.ClientID %>");  
             
                    if (menuItem.get_text() == "Update") {  
                        treeNode.collapse();  
                        tree.trackChanges();  
                        treeNode.get_nodes().clear();  
                        tree.commitChanges();  
                        treeNode.expand();  
                    }  
 
                } 

But the expand() does not cause the load on demand of the childs, and also clicking the node does not cause the load on demand

There is a way to solve this?

Thanks

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 11 Sep 2008, 10:13 AM
Hi SeRiAlKiL,

When the node added its children after the first expand, its expand mode is changed to ClientSide. That is why on the second expand the NodeExpand server event does not fire.

I suggest that after clearing the nodes you set the expand mode of the root node to ServerSideCallBack like this:

node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack);

I hope this helps.

Regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
SeRiAlKiL
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or