RadTreeView - Get Width

4 posts, 0 answers
  1. Kyle
    Kyle avatar
    23 posts
    Member since:
    Jun 2013

    Posted 11 Jun 2014 Link to this post

    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>
  2. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 16 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kyle
    Kyle avatar
    23 posts
    Member since:
    Jun 2013

    Posted 16 Jun 2014 in reply to Plamen Link to this post

    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?
  5. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 19 Jun 2014 Link to this post

    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.

     
Back to Top