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

Unable to catch node expansion after creating its first child and expanding in client side code

5 Answers 44 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mallverkstan
Top achievements
Rank 2
Mallverkstan asked on 15 Jan 2009, 12:03 PM
Hi again,

it appears that the ClientNodeExpanding event is not fired when a node that has no children gets a child, and is then expanded with node.expand(). It also doesn't fire with node.set_expanded(true). Here is a sample code:

        var retvals = retval.split("|"); /* retval is a string such as :
"10879|Produktgrupp ┬źNy produktgrupp┬╗|PRODUKTGRUPP|/Icons/TreeView/ImageCreate.aspx?nodetype=PRODUKTGRUPP&alias=False&icontype=normal|/Icons/TreeView/ImageCreate.aspx?nodetype=PRODUKTGRUPP&alias=False&icontype=expanded|Ny produktgrupp" */   
        var node_id = retvals[0]; 
        var tooltip = retvals[1]; 
        var category = retvals[2]; 
        var imageurl = retvals[3]; 
        var expimageurl = retvals[4]; 
        var nodename = retvals[5]; 
                 
        var node = new Telerik.Web.UI.RadTreeNode();  
        node.set_text(nodename.replace(/</g,"&lt;").replace(/>/g, "&gt;")); 
        node.set_target("content"); 
         
        node.set_value(node_id);     
        var navurl = "content.aspx?id_catalogue=1&data_id_node="+node_id+"&id_category="+category+"&tree_id_node="+node_id; 
        node.set_navigateUrl(navurl);    
        node.set_imageUrl(imageurl); 
        node.set_expandedImageUrl(expimageurl); 
        node.set_contextMenuID(category); 
        node.set_category(category);         
         
// g_parent_node is a global variable with the parent node
        g_parent_node.get_nodes().insert(0, node); 
 
        node.get_textElement().title = tooltip; 
         
        if (!g_parent_node.get_expanded()) {             
            g_parent_node.expand();
/* If g_parent_node had no childnodes before I added one in the code above,
this expansion can not be caught!! Nither ClientNodeExpanding nor ClientNodeExpanded is fired. But g_parent_node is actually expanded!
*/
        } 

If I do g_parent_node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack) before expanding, the ClientNodePopulated event is fired, but that is not what I want.

Regards,
Fredrik
Mallverkstan

5 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 15 Jan 2009, 12:28 PM
Hello Mallverkstan,

Please check this troubleshooting topic:
Troubleshooting > Expanding nodes

Greetings,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mallverkstan
Top achievements
Rank 2
answered on 15 Jan 2009, 01:15 PM
Thank you Veselin.

You could have added that information to http://www.telerik.com/help/aspnet-ajax/tree_clientonclientnodeexpanding.html, http://www.telerik.com/help/aspnet-ajax/tree_clientonclientnodeexpanded.html and http://www.telerik.com/help/aspnet-ajax/tree_clientradtreenode.html (on expand() and set_expand()).



Anyways, I have modified the last part of my code to be like this:
        if (!g_parent_node.get_expanded()) { 
            if (g_parent_node.get_expandMode() == 0) { 
                setTimeout(function() { node.highlight(); node.startEdit(); }, 300); 
            } 
            else 
            { 
                g_save_node.expand(); 
            }    
        } 

This works. However, I would prefer to have something like the ClientNodePopulated event that is fired after all nodes have been completely loaded, without the need for a timer function.

With regards,
Fredrik
Mallverkstan

0
Veselin Vasilev
Telerik team
answered on 19 Jan 2009, 04:19 PM
Hello Mallverkstan,

We have updated the help articles as per your suggestion. We updated your Telerik Points for that as well.

As for the other question - have you tried using the OnClientLoad event of the treeview?

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mallverkstan
Top achievements
Rank 2
answered on 21 Jan 2009, 10:59 AM
Hi Veselin,

thanks for the suggestion;
I have never used the OnClientLoad event, assuming it only fired once per page load?

Sincerely
Fredrik
Mallverkstan


0
Veselin Vasilev
Telerik team
answered on 23 Jan 2009, 04:39 PM
Hello Mallverkstan,

Yes, that is correct.

Regards,
Veselin Vasilev
the Telerik team

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