treeview with radwindow

5 posts, 2 answers
  1. regina
    regina avatar
    40 posts
    Member since:
    Sep 2012

    Posted 17 Sep 2012 Link to this post

    I have a treeview with data that can become quite long.  also if you double click a node I am opening a radwindow with additional data for the node.  Is there a way to open the radwindow over the location in the treeview?  Currently it is always at the top.
    thanks.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Sep 2012 Link to this post

    Hi Regina,

    I suppose you want to open the RadWindow based on the location of the RadTreeNode. Following is the sample code that I tried based on your scenario.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientDoubleClick="OnClientDoubleClick">
      <Nodes>
        <telerik:RadTreeNode Text="RadTreeNode1">
        </telerik:RadTreeNode>
        <telerik:RadTreeNode Text="RadTreeNode2">
        </telerik:RadTreeNode>
        <telerik:RadTreeNode Text="RadTreeNode3">
        </telerik:RadTreeNode>
        <telerik:RadTreeNode Text="RadTreeNode4">
        </telerik:RadTreeNode>
      </Nodes>
    </telerik:RadTreeView>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
      <Windows>
        <telerik:RadWindow ID="RadWindow1" runat="server">
        </telerik:RadWindow>
      </Windows>
    </telerik:RadWindowManager>

    JS:
    <script type="text/javascript">
        function OnClientDoubleClick(sender, args) {
            var node = args.get_node();
            var nodeElement = node.get_contentElement();
            var treeViewElement = sender.get_element();
            var nodeOffsetTop = sender._getTotalOffsetTop(nodeElement);
            var treeOffsetTop = sender._getTotalOffsetTop(treeViewElement);
            var relativeOffsetTop = nodeOffsetTop - treeOffsetTop + 5;
            var oWnd = radopen(null, "RadWindow1");
            oWnd.MoveTo(100, relativeOffsetTop);
        }
    </script>

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. regina
    regina avatar
    40 posts
    Member since:
    Sep 2012

    Posted 18 Sep 2012 Link to this post

    Princy, thank you this does almost everything I need.  I have been able to get the selectednode with 

     

     

    var SelectedNode_Tree = args._node._control._selectedValue;

     


    however there is an overall issue in that after double clicking a node once those seem to always be the values passed to the

    OnClientDoubleClick

    function.  How do I get it to refresh?
  5. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 19 Sep 2012 Link to this post

    Hello Regina,

    I will suggest you to use this approach to access the selected node and its value:
    //JavaScript

    function OnClientDoubleClick(sender, args) {   
                var node = args.get_node();
              var nodeValue = args.get_node().get_value();
    .........
    }

    //aspx file

    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientDoubleClick="OnClientDoubleClick">
            <Nodes>
                <telerik:RadTreeNode Text="RadTreeNode1" Value="1" >
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="RadTreeNode2" Value="2" >
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="RadTreeNode3" Value="3" >
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="RadTreeNode4" Value="4" >
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>

    By setting a default value of each RadTreeNode would be easier to test.

    I hope this was helpful.


    Kind regards,
    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. regina
    regina avatar
    40 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2012 Link to this post

    thank you that fixed it.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017