Determining the width of a TreeView from server-side

3 posts, 0 answers
  1. Jesse Lawler
    Jesse Lawler avatar
    46 posts
    Member since:
    Apr 2010

    Posted 26 Jul 2010 Link to this post

    I've got a TreeView object with no specified Width parameter -- so its width is just defined by the nodes inside of it.  Here's my question:  Is there a way on the server-side for me to calculate the width of the total TreeView, after its nodes have been programmatically loaded?

    Thanks!

    PS:  Come to think of it, I could just as easily do what I'm after on the client-side, too -- so any way of determining the actual height/width of a populated TreeView, client-side or server-side, would be great.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jul 2010 Link to this post

    Hello,


    Use the following client code in order to get the width and height from client-side.

    Client code:
    <script type="text/javascript">
        function getWidth() {
            var treeView = $find("<%=RadTreeView1.ClientID%>");
            alert("width: " + treeView.get_element().clientWidth);
            alert("height: " + treeView.get_element().clientHeight);
      
        }
    </script>


    If you want to access the same values from code behind, then save the value in HiddenField and access from server code.


    Thanks,
    Princy.
  3. Jesse Lawler
    Jesse Lawler avatar
    46 posts
    Member since:
    Apr 2010

    Posted 27 Jul 2010 Link to this post

    Perfecto!  Thank you.
Back to Top