RadTreeView Drag&Drop -ServerSide

6 posts, 0 answers
  1. Cos
    Cos avatar
    5 posts
    Member since:
    Mar 2009

    Posted 23 Mar 2009 Link to this post

    Hi

    I have a treeview with drag and drop enabled. I'm constructing the treeview programatically.
    I want to update the nodes (server side) when I drop into new position.

    Can I use an AJAXRadPanel with serverside code to stop full postback?
    Also can I keep the dropped node selected once a postback has occured?

    If so does anybody have any samples?

    Many Thanks

  2. Yana
    Admin
    Yana avatar
    5024 posts

    Posted 24 Mar 2009 Link to this post

    Hi there,

    Using RadAjaxPanel to stop full postback is the best solution in your case. I've attached a simple page demonstrating this approach, also the dropped node is selected. Please download it and give it a try.

    Greetings,
    Yana
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Cos
    Cos avatar
    5 posts
    Member since:
    Mar 2009

    Posted 24 Mar 2009 Link to this post

    Thanks for your reply. I had a few issues with incorporating your postback solution and I didn't elaborate enough on my issue yesterday...

    My treeview has attributes associated with each node that stores the order number. For example;
    Node  |   Order
    1             1
    2             2
    3             3
    4             4
    5             5

    Moving Node 4 above Node 2 means it would look like (in database)
    Node  |   Order
    1             1
    2             3
    3             4
    4             2
    5             5

    On postback using your example the new attribute are not coming back through. The nodes are retaining their position but hold the incorrect attribute value. I am using RadTreeView_NodeDataBound to add attribute values.

    Is this still possible - I also want to incorporate load on demand to this scenario at some point - will this be possible?
  4. Yana
    Admin
    Yana avatar
    5024 posts

    Posted 25 Mar 2009 Link to this post

    Hello,

    You should manually set Order attribute to all nodes according to their new order. I've modified the project to show you how you can do that.

    Best wishes,
    Yana
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Cos
    Cos avatar
    5 posts
    Member since:
    Mar 2009

    Posted 06 Apr 2009 Link to this post

    Thanks for the reply, this does work but only when the button postsback.

    In my scenario the order is not updating. I am using the attribute value to pass through to a stored proc which updates order in table.

    As an example to demonstrate my result, if I add a tooltip for each node in the RadTreeView_NodeDataBound from the example you gave me, the attribute value doesn't update.

    e.Node.ToolTip = (e.Node.DataItem as DataRowView)["Order"].ToString(); 

    How can I update the value?

    Many thanks in advance.


  6. Yana
    Admin
    Yana avatar
    5024 posts

    Posted 08 Apr 2009 Link to this post

    Hi there,

    The Tooltip value should be updated when the value of "Order" is updated - in PerformDragAndDrop method like this:

    ...  
     case RadTreeViewDropPosition.Above:  
                    // sibling - above                      
                    destNode.InsertBefore(sourceNode);  
                    for (int i = 0; i < destNode.TreeView.Nodes.Count; i++)  
                    {  
                        destNode.TreeView.Nodes[i].Attributes["Order"] = (i + 1).ToString();  
                        destNode.TreeView.Nodes[i].ToolTip = destNode.TreeView.Nodes[i].Attributes["Order"];  
                    }  
                    break;  
     
                case RadTreeViewDropPosition.Below:  
                    // sibling - below  
                    destNode.InsertAfter(sourceNode);  
                    for (int j = 0; j < destNode.TreeView.Nodes.Count; j++)  
                    {  
                        destNode.TreeView.Nodes[j].Attributes["Order"] = (j + 1).ToString();  
                        destNode.TreeView.Nodes[j].ToolTip = destNode.TreeView.Nodes[j].Attributes["Order"];  
                    }  
                   break;  
    ... 


    Kind regards,
    Yana
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top