prevent drag and drop when node reaches 4th tier

16 posts, 0 answers
  1. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 16 Mar 2010 Link to this post

    Hi,

    I would like to ask if the telerik treeview has this functionality that when the treeview has reached the 4th tier, no nodes can be dropped in that node.

    For example:
    Parent 1
     >child 1
        >granchild 1
            >grandchild 2
    Parent 2

    is there a way that i can prevent this if I try to drag and drop the parent 2 in the grandchild 2?

    Thanks
    Jhobs
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Mar 2010 Link to this post

    Hello Jhobs,

    You can check for the destination node's level in the OnClientNodeDropping event and cancel the event if level is four. Here is the example.

    JavaScript:

     
    <script type="text/javascript">  
        function OnClientNodeDropping(sender, args) {  
            if (args.get_destNode().get_level() > 3) {  
                alert('Cannot drop node here');  
                args.set_cancel(true); // Cancel the event  
            }  
        }  
    </script> 

     

    Regards,

    Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 16 Mar 2010 Link to this post

    Thanks Shinu... :-)

    I have a follow up question, what if I want to prevent users from dragging node in a specific node? can I specify the title of the node that i want to cancel the event?

    Thank you very much :)
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 Mar 2010 Link to this post

    Hi Jo Bert,

    You can also set AllowDrop property of these nodes to false when you create them.


    All the best,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 17 Mar 2010 Link to this post

    Hi Yana,

    the AllowDrag is only available if you create the <nodes><telerik:radtreenode> in the treeview right? but what if i have an xml as my xmldatasource? how can i specify one node in that xml that will not have drag and drop functionality?

    Thanks
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Mar 2010 Link to this post

    Hello Jo Bert,

    You can subscribe to OnNodeCreated event and set this property in its handler.

    Best wishes,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 19 Mar 2010 Link to this post

    Thanks Yana... But what if I'm just creating the node on the fly. what i mean is i am only creating the node like this:

    dim node as string = <parent id="1" url="" title="">

    and then i added this to the xml string which the radtreeview is loading.

  9. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 23 Mar 2010 Link to this post

    I also have problem with counting the depth of the parent node. what i want to happen is that no items should be added when the treeview reaches the 4th tier.

    Here is another scenario:
    Parent1
         Child 1
              Child2
    Parent2
          Child4

    What if i drag parent2 under child 2? The expected behavior here is that it will still allow the the Parent2 to be added because it will be the 4th tier of the treeview. But this will also display the child of the Parent2 making the levels of the treeview to 5 tiers.

    Parent1
         Child 1
              Child2
                  Parent2
                        Child4
    Is there a way to check both the sourcenode and destnode on node drop? that if the number of tiers of the two exceeded 4 tiers, this will prompt a message box?

    Thanks
  10. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 Mar 2010 Link to this post

    Hello Jo Bert,

    You can use the nodes get_level() client-side method in OnClientNodeDropping event and cancel the dropping. Full list of the client-side methods of a node can be found here.

    Regards,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  11. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 25 Mar 2010 Link to this post

    Thanks Yana. I'll just play around with those client script. Though I still have another question. in the Rad Treeview, we can specify the xml file it will use, we just have to specify the XPath right? my question is, after the treeview loads the xml file and displays the right nodes, is there a way to get the XML code of a treeview? I've read that Radtreeview.GetXML retrieves the xml file of the treeview but it does not return the xml format same as the one we specify in the new xml file.

    Thanks
  12. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Mar 2010 Link to this post

    Hi Jo Bert,

    GetXml()  is the only method that RadTreeView provides to return its structure in xml format.  What exactly is your xml format?

    Kind regards,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  13. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 29 Mar 2010 Link to this post

    Hi Yana,

    The xml i load in the tree view is something like this, <List><Parent></Parent></List>. But i use the GetXML method of the treeview it returns <Tree><Node></Node></Tree>. Is there a way that the radtreeview can return the xml I load? because i need to get the current of the treeview upon drag and drop.

    Does the new telerik version behaves the same?

    Thanks
  14. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 30 Mar 2010 Link to this post

    Hi Jo Bert,

    I'm afraid that GetXml returns the treeview in exactly this format.

    Regards,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  15. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 05 Apr 2010 Link to this post

    Thanks Yana, another thing, does the Getxml method of the treeview retrieves the exact pattern of the treeview.
    for example, I enabled the drag and drop property of the treeview then i also have a button which onclick will get the xml of the treeview control. If i reordered my treeview then call the GetXML Method, will this return the xml same as what I reordered the control?

    Thanks
  16. Dimitar Milushev
    Admin
    Dimitar Milushev avatar
    555 posts

    Posted 07 Apr 2010 Link to this post

    Hi Jo Bert,

    If you do it after reordering the Tree Nodes, the GetXml will return the current, i.e. reordered state of the TreeView.

    All the best,
    Dimitar Milushev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  17. Jo Bert
    Jo Bert avatar
    41 posts
    Member since:
    Aug 2008

    Posted 07 Apr 2010 Link to this post

    Thanks Dimitar...

    maybe you also have an answer with my other thread http://www.telerik.com/community/forums/aspnet-ajax/treeview/get-nodes-count-on-onnodedropping-function.aspx.

    thanks a lot.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017