Autosize TreeList Columns

5 posts, 1 answers
  1. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 01 Apr Link to this post

    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.

  2. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 05 Apr Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 06 Apr in reply to Nikolay Rusev Link to this post

    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?

  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 08 Apr Link to this post

    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!
     
  6. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 08 Apr Link to this post

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

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

Back to Top
Kendo UI is VS 2017 Ready