TreeView and Horizontal Scrolling

Date: January 5, 2007

Component:TreeView

Version: v0.12.1

This simple example is designed to illustrate the simplest approach to allowing a TreeView Control implementation to spread out horizontally beyond the dimensions allocated for it on the page. If a TreeView is constrained spatially, its visual treatment will degrade. To prevent this:

  • Wrap the element into which your TreeView will be rendered within a container element. Do not specify a width for the element into which you're rendering your TreeView; allow it to expand horizontally as needed.
  • Using CSS, specify a width for the container element.
  • Using CSS, specify the overflow-x property to be auto.

If you were to write the CSS inline, the markup for this solution would look as follows:



Please note that text in your tree will wrap if it can — this technique will only force scrolling if the TreeView instance can not naturally be constrained within the given space. To force scrolling even when the tree is not constrained, you would need to wrap parentTreeDiv around an inner element with a width set to the desired width allocated for your tree.

(c)2010 Yahoo Inc.