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

Autosize TreeList Columns

4 Answers 411 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 01 Apr 2016, 02:06 PM

Is it possible to autosize the columns of a treelist such that each column is as wide as the widest entry (or the column header)?  I don't want to hard-code column width values for each column as the number of columns we might use is dynamic.

I'm currently playing around with the TreeList here:  http://dojo.telerik.com/epOQe

I can autosize the column by double clicking the column splitter; I'd love to be able to do that programmatically.

4 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 05 Apr 2016, 06:26 AM

Hello Matt,

 

There is a auto-fit feature in the TreeList which changes the width of the column based on the larger content in all data cells.

 

This feature is active when resizable is enabled and on double click in the header between two cells. There is also a API method autoFitColumn which you can call manually. It doesn't require resizable to be enabled. 

 

You can use this method to size the column, but the columns should be populated with data. That means that you might need to wait for dataBound to happen.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matt
Top achievements
Rank 1
answered on 06 Apr 2016, 01:50 PM

This works fine for a grid, but not for a treelist.  As you can see in this dojo (http://dojo.telerik.com/iZipu), the autoFitColumn works fine for a grid, but in this dojo (http://dojo.telerik.com/urAku) -- using a treelist -- it does not.  (The third message box doesn't display, indicating to me it errored out when attempting to execute the non-existent autoFitColumns command.)

It also appears there's no method for autoFitColumns according to the documentation for treelists (http://docs.telerik.com/kendo-ui/api/javascript/ui/treelist).

So...is this indeed not supported for treelists?

0
Nikolay Rusev
Telerik team
answered on 08 Apr 2016, 06:52 AM

Hello Matt,

 

There is a typo in your dataBound event handler. You will notice it once you open browser console. Here is updated dojo which seems to work properly.

 

Regarding the documentation we will update the TreeList API article with the method.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matt
Top achievements
Rank 1
answered on 08 Apr 2016, 11:39 AM

Doh...stupid typos; thanks for the second set of eyes.

autoFitColumns is exactly what I'm looking for and works like a champ!

Tags
TreeList
Asked by
Matt
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Matt
Top achievements
Rank 1
Share this question
or