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

RadTreeView - Get Width

3 Answers 124 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 11 Jun 2014, 10:21 PM
Hi All,

I have this function in C# that I use in windows forms which allws me to get the width of the treeview:

private static int GetNodeBounds(TreeNodeCollection nodes)
{
int w = 0;
foreach (TreeNode node in nodes)
{
w = Math.Max(w, node.Bounds.Right);
if (node.Nodes.Count > 0)
w = Math.Max(w, GetNodeBounds(node.Nodes));
}
return w;
}


I'm looking for something similiar in javascript.  Essentially what I'm trying to do is find the width of the tree view based on the displayed nodes so that I can resize the splitter.

Any suggestions?


function ClientNodeExpand(sender, eventArgs) {

}


<telerik:RadPageView runat="server" ID="tabBMR" Width="100%">
<telerik:RadSplitter runat="server" ID="splitter" Orientation="Vertical" Width="100%">
<telerik:RadPane runat="server" ID="RadPane1" Style="text-align: center; width: auto !important">
<div style="font-size: 2EM; text-align: center">
Step 1</div>
<telerik:RadTreeView runat="server" ID="tvNodes" Height="90%" OnClientNodeExpanded="ClientNodeExpand"
CheckChildNodes="True" CheckBoxes="True">
</telerik:RadTreeView>
<div style="text-align: center">
<br />
<asp:Button ID="Button1" runat="server" Text="Add Item(s)" />
</div>
</telerik:RadPane>
<telerik:RadSplitBar ID="Radsplitbar3" runat="server">
</telerik:RadSplitBar>
<telerik:RadPane runat='server' ID="RadPane2" Width="74%">
    Test 2
</telerik:RadPane>
</telerik:RadPageView>

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 16 Jun 2014, 01:22 PM
Hello Kyle,

Basically the width of RadTreeView is not changing when it is collapsed or expanded and that is why such javascript method will not be returning different values. 

hope this will explain the issue.

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Kyle
Top achievements
Rank 1
answered on 16 Jun 2014, 03:33 PM
So how do I get the width of the max width of the nodes or is there a way to find out how much the splitter distance should be?
0
Plamen
Telerik team
answered on 19 Jun 2014, 02:06 PM
Hello,

It looks like I could not explain properly. Unfortunately getting the max width of the nodes is not supported scenario by the control. Please excuse us for this limitation of the control.

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Kyle
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Kyle
Top achievements
Rank 1
Share this question
or