RadWindow + drag n drop

7 posts, 1 answers
  1. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 18 May 2009 Link to this post

    Hi

    I am having a Rad treeview and I am dragging and dropping a radwindow from the treeview nodes. Its working fine. What I need is that I need the control of dropping my window i.e. if I drop the radwindow in left side it should come in left or else if I drop in right side, its hould in right. how shall i do that?

    Please find below the codes I am using..
    <telerik:RadSlidingPane ID="RadSlidingPane1" runat="server" Title=">>" EnableDock="true" Width="200px">
                        <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientMouseOver= "OnClientMouseOver"
                        OnClientNodeDragStart = "openDashboards" EnableDragAndDrop="true">
    </telerik:RadTreeView>

    Below is the javascript:-

    function openDashboards(sender, eventArgs)
            {
                    var nodeElem = eventArgs.get_node();
                    
                        var title = eventArgs.get_node(sender, eventArgs).get_text();
                        var link = eventArgs.get_node(sender, eventArgs).get_value();
                        var oWnd = radopen(link,"RadWindow" + counter);
                        oWnd.set_title(title);
             }

    I think I am missing some property in treeview to have contril over my dropping window. Please help

    Thanks
    Arindam
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 18 May 2009 Link to this post

    Hello Arindam,

    I would suggest to use the OnClientNodeDropping eventhandler and to get the coordinates of where you have released the mouse. Then you can use RadWindow's moveTo() method to move the window there.
    e.g.:

    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <telerik:RadTreeView ID="RadTreeView1" EnableDragAndDrop="true" runat="server" OnClientNodeDropping="OnClientNodeDropping"
        <Nodes> 
            <telerik:RadTreeNode runat="server" Text="RadTreeNode1"
            </telerik:RadTreeNode> 
            <telerik:RadTreeNode runat="server" Text="RadTreeNode2"
            </telerik:RadTreeNode> 
            <telerik:RadTreeNode runat="server" Text="RadTreeNode3"
            </telerik:RadTreeNode> 
            <telerik:RadTreeNode runat="server" Text="RadTreeNode4"
            </telerik:RadTreeNode> 
        </Nodes> 
    </telerik:RadTreeView> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
    </telerik:RadWindowManager> 
     
    <script type="text/javascript"
    function OnClientNodeDropping(sender,args) 
        var xPos = args.get_domEvent().offsetX; 
        var yPos = args.get_domEvent().offsetY 
        var oWnd = radopen("http://www.google.com",null); 
        oWnd.moveTo(xPos,yPos); 
    </script> 
     


    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 18 May 2009 Link to this post

    Hello Admin - Thanks for your reply
    I modified my javascript a little bit, please find below:-
    function OnClientNodeDropping(sender,eventArgs)
            {
                var xPos = eventArgs.get_domEvent().offsetX;
                alert(xPos);
                var yPos = eventArgs.get_domEvent().offsetY;
                
                var title = eventArgs.get_node(sender, eventArgs).get_text();
                alert(title);
                var link = eventArgs.get_node(sender, eventArgs).get_value();
                var oWnd = radopen(link,null);
                oWnd.moveTo(xPos,yPos);
            }
    In the line var title = eventArgs.get_node(sender, eventArgs).get_text(); I am getting error, that it is undefined. Basically purpose of this is to get the link title and value of the dragged node of my treeview.

    Please help.

    Thanks
    Arindam
  4. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 18 May 2009 Link to this post

    Hello Arindam,

    Remove sender and eventArgs parameters from the get_node() method - this syntax is incorrect.
    e.g.
    var title = eventArgs.get_node(sender, eventArgs).get_text();

    should be
    var title = eventArgs.get_node().get_text();

    and

    a   var link = eventArgs.get_node(sender, eventArgs).get_value();

    should become
    var link = eventArgs.get_node().get_value();

    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 18 May 2009 Link to this post

    Hi Georgi!

    Thanks for your reply. I changed as you told, please check below:-
     function OnClientNodeDropping(sender,eventArgs)
            {
                var xPos = eventArgs.get_domEvent().offsetX;
                var yPos = eventArgs.get_domEvent().offsetY;
                var title = eventArgs.get_node().get_text();
                var link = eventArgs.get_node().get_value();  
                var oWnd = radopen(link,null);
                oWnd.moveTo(xPos,yPos);
            }

    I am getting an error: Error: Object doesn't support this property or method on var title = eventArgs.get_node().get_text();

    Please reply...

    Thanks
    Arindam
  6. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 18 May 2009 Link to this post

    Hi-

    I figure out the problem, tell if its right. Please find the code below:-
    function OnClientNodeDropping(sender,eventArgs)
            {
                var xPos = eventArgs.get_domEvent().offsetX;
                //alert(xPos);
                var yPos = eventArgs.get_domEvent().offsetY;
                
                var title = eventArgs.get_sourceNode().get_text();
                alert(title);
                var link = eventArgs.get_sourceNode().get_value();  
                alert(link);        
                var oWnd = radopen(link,title);
                oWnd.set_title(title);
                oWnd.moveTo(xPos,yPos);
            }

    Thanks
    Arindam
  7. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 19 May 2009 Link to this post


    Yes, Arindam, this is the correct way.

    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top