TreeList Column Width
This article explains how to set TreeList column widths and how the component behaves, depending on its column width configuration.
Basics
The TreeList renders separate HTML <table> elements for its header and data areas. This allows users to scroll the data area vertically, while the header area remains visible at all times. The TreeList tables apply table-layout: fixed and width: 100% CSS styles to ensure column alignment between the three areas.
You can set the TreeList column Width parameter in any CSS unit, such as px, %, vw, em, rem. Unit-less Width values are not supported. You can read more on how to set sizes in Telerik components in the Dimensions article.
Column Width Behavior
The TreeList column width settings can vary and result in the following behaviors:
| The Sum of All Set Column Widths Is: | |||
|---|---|---|---|
| Greater Than the TreeList Width | Less Than the TreeList Width | ||
| How Many Columns Have Width: | All |
|
|
| Some |
|
| |
| None |
| ||
To allow the users to adjust or auto-fit the column widths to the content, enable TreeList column resizing. You can also resize columns through the TreeList state or auto-fit columns programmatically.
Single table rendering and automatic table layout are not supported.
Recommendations
For predictable and user-friendly behavior, consider the following TreeList configuration:
- If the TreeList has a fixed width and you need horizontal scrolling, set widths to all columns. Use absolute units that do not depend on the browser viewport size.
- If the TreeList does not need horizontal scrolling and is not likely to shrink too much, then leave at least one column without a width. This ensures that all set column widths are respected and the width-less columns take up the remaining space.
- If the TreeList width is unpredictable and the width-less columns may shrink too much, then apply a
min-widthstyle to the TreeList tables, according to the example below.
Apply a minimum width to the TreeList table in a responsive layout