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

6 posts, 1 answers
  1. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 15 Jan 2009 Link to this post

    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
  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Jan 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 15 Jan 2009 Link to this post

    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

  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 19 Jan 2009 Link to this post

    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.
  6. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 21 Jan 2009 Link to this post

    Hi Veselin,

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

    Sincerely
    Fredrik
    Mallverkstan


  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 23 Jan 2009 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017