How to check whether the current node is expanded

6 posts, 0 answers
  1. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 03 Mar 2009 Link to this post

    Hi Princy,
        I have implemented the On Demand Loading . There is a provision in my tree view control user can right click and select the option "Add a New Node" context menu item and can add a new items . But I want some thing like if the current node on which the mouse curse is not expanded( That means it is displaying the '+' symbol ) I have to inform the user to expand the node or I have to expand the node when user right clicks on the node . Can you please suggest me how can I able to know whether the current node is expanded or not ?

    With Regards
    Manoj
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2009 Link to this post

    Hi Manoj,

    Try the following code snippets for alerting user if node is not expanded and currently on right clicking the node. Attach the ClientContextMenuShowing() handler to OnClientContextMenuShowing event of RadTreeView.

    JavaScript:
    <script type="text/javascript">  
    function ClientContextMenuShowing(sender, eventArgs)  
    {  
         var node = eventArgs.get_node();     
         if(node.get_expanded()==false)  
         {  
            alert("Node is not expanded, First expand the node");  
         }  
    }  
    </script> 

    Thanks,
    Princy.
  3. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 04 Mar 2009 Link to this post

    Hi Princy,
                Thanks for your reply . I tried to use your suggested code but now the default window context menu is coming up . Can you suggest me how can I avoid this .

    function

    onClientContextMenuShowing(sender, args)

     

    {

     

     

    var treeNode = args.get_node();

     

     

     

    if(treeNode.get_expanded()==false)

     

    {

    alert(

     

    "Node is not expanded, First expand the node");

     

    args.set_cancel(

     

    true);

     

    }

     

     

    else

     

     

    {

    treeNode.set_selected(

    true);

     

    setMenuItemsState(args.get_menu().get_items(), treeNode);

    }

    }

    Regards
    Manoj

     

  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2009 Link to this post

    Hi Manoj,

    I tried to following code for cancelling the mouse click event. Try the JavaScript code.

    JavaScript:
    <script type="text/javascript">  
    function OnClientContextMenuShowing(sender, eventArgs)  
    {  
         var node = eventArgs.get_node();  
         if(node._hasChildren()) //checking whether the node having children  
         {  
             if(node.get_expanded()==false)  
             {  
                alert("Node is not expanded, First expand the node");  
                eventArgs.set_cancel(true);  
                try   
                {  
                    var e = window.event;  
                    if(!e) e = window.Event;  
                    if(e)   
                    {  
                        e.returnValue = false;  
                        e.cancelBubble = true;  
                        e.stopPropagation();  
                    }  
                } catch(c) {}  
                return false;  
            }  
        }  
        else 
        {  
            node.set_selected(true);  
          //  setMenuItemsState(eventArgs.get_menu().get_items(), node);  
        }  
    }  
    </script> 

    Thanks,
    Princy.
  5. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 04 Mar 2009 Link to this post

    Hi Princy,
        Its work fine . Thanks .

    Regards
    Manoj
  6. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 05 Mar 2009 Link to this post

    Hi Princy,
        As I have implemented the Load On Demand , so I am expanding the leaf level node as client side . But when I am clicking the leaf level node I am getting the same message . It is working fine for the nodes which were not expanded ( having '+' symbol ) but not working for the leaf level node . Can you suggest me what should I do for this .

    Regards
    Manoj

Back to Top