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

Determining the width of a TreeView from server-side

2 Answers 79 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jesse Lawler
Top achievements
Rank 1
Jesse Lawler asked on 27 Jul 2010, 02:43 AM
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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Jul 2010, 02:35 PM
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.
0
Jesse Lawler
Top achievements
Rank 1
answered on 27 Jul 2010, 06:22 PM
Perfecto!  Thank you.
Tags
TreeView
Asked by
Jesse Lawler
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jesse Lawler
Top achievements
Rank 1
Share this question
or