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

[Solved] Problem collapse function in ClientNodeExpanded

3 Answers 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
VANDENBERGHE
Top achievements
Rank 1
VANDENBERGHE asked on 05 Jun 2008, 07:41 AM
Hi everyone,

I didn't succeed in using the javascript function node.collapse() in the OnClientNodeExpanded event. Please, find below my code sample :

ASPX :  
 
<telerik:RadTreeView ID="TreeView1" runat="server" PersistLoadOnDemandNodes="true" Skin="Black" OnNodeClick="RadTreeView1_SelectedNodeClick" OnNodeExpand="RadTreeView1_NodeExpand" OnClientNodeExpanded="ClientNodeExpanded" /> 
 
JAVASCRIPT :  
 
    <script type="text/javascript" language="javascript">  
        function ClientNodeExpanded(sender, eventArgs)  
        {  
            var node = eventArgs.get_node();  
            if (node.get_nodes() == null  
                || node.get_nodes().get_count() == 0)  
            {              
                node.collapse();                               
                var toggleElement = node.get_toggleElement();  
                if (toggleElement)  
                    toggleElement.style.display = "none";  
            }  
        }     
    </script> 
 
 

The node ExpandMode is ServerSideCallBack. When I run my application, The toggle mark is hide but the node is not collapsed. Is it normal to not be able to use the node.Collapse() method in this event ?

I'm really not be able to compute the number of children of the nodes like in your Demo before trying to expand it. I consume data from another application and it's pretty long for each node. So I need to collapse the node and hide the toggle element after the expand depending on the number of children.

Reagrds,
Sebastien

3 Answers, 1 is accepted

Sort by
0
VANDENBERGHE
Top achievements
Rank 1
answered on 05 Jun 2008, 08:54 AM
My previous post is for version 2008.1.415.35 and I just tested with 2008.1.515.20 and for this version the toggle element disappear each time I expand a node even if the node has children... It's like with ServerSideCallback mode, the event OnClientNodeCollapsed is fired before collapse. Is it normal ?
0
Accepted
Atanas Korchev
Telerik team
answered on 05 Jun 2008, 09:03 AM
Hi VANDENBERGHE,

I have prepared a sample web page which demonstrates the required approach. Please find it attached to this forum thread.

I hope this helps,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
VANDENBERGHE
Top achievements
Rank 1
answered on 05 Jun 2008, 09:16 AM
Thanks a lot,

Your sample is simply GREAT.

Regards,
Sebastien
Tags
TreeView
Asked by
VANDENBERGHE
Top achievements
Rank 1
Answers by
VANDENBERGHE
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or