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
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
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?
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
Doh...stupid typos; thanks for the second set of eyes.
autoFitColumns is exactly what I'm looking for and works like a champ!