This is a migrated thread and some comments may be shown as answers.

treeview with radwindow

4 Answers 96 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
regina
Top achievements
Rank 1
regina asked on 17 Sep 2012, 05:16 PM
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.

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Sep 2012, 06:10 AM
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.
0
regina
Top achievements
Rank 1
answered on 18 Sep 2012, 12:41 PM
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?
0
Accepted
Boyan Dimitrov
Telerik team
answered on 19 Sep 2012, 08:50 AM
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.
0
regina
Top achievements
Rank 1
answered on 19 Sep 2012, 01:37 PM
thank you that fixed it.
Tags
TreeView
Asked by
regina
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
regina
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or