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

[Solved] ClientNodeExpanding canceling postback, but not the expand

2 Answers 191 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 16 May 2008, 02:34 PM

Hi

My tree control handles the NodeExpand event on the server. It also handles the client NodeExpanding event.

If the user clicks the expand icon on a tree node, I thought it would be efficient to check on the client side to see whether I have already got child nodes. If I have child nodes then there is no need to do a postback. However, I do still want the node to expand as the client has all the node data.

My problem is - How do I cancel the postback, but allow the node to expand?

Thanks,
Martin

    function onClientNodeExpanding(sender, args)  
    {  
        var childrencount = args.get_node().get_nodes().get_count();  
        if (childrencount > 0)  
        {  
            //don't cause a post back as we already have the children. However, we do actually want to expand   
            args.set_cancel(true);  
        }  
    }  
 

2 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 16 May 2008, 03:39 PM
Hi Martin,

You can set the ExpandNode of the expanded node to ClientSide in your NodeExpand handler and the TreeView will behave as expect it (loading nodes only once) without any client-side code. You can see this in action in this example - http://www.telerik.com/demos/aspnet/prometheus/TreeView/Examples/Programming/LoadOnDemandSql/DefaultCS.aspx

Kind regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Martin
Top achievements
Rank 1
answered on 16 May 2008, 04:20 PM
Hi
Thanks for your response.

My real problem is that I am unable to drag and drop tree nodes over an ActiveX control.

I have made some tests and it is possible to do it with a normal html image element using the onDragEnd event/property.
<img src="Images/folder.gif" ondragend="alert('dropped');" /> 

I have been playing with the templates, hoping that creating my own image element, setting the onDragEnd property would do the trick. However, it would appear that the tree control consumes any dragging I wish to attempt.

Is there another way?
Martin
Tags
TreeView
Asked by
Martin
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Martin
Top achievements
Rank 1
Share this question
or