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

Problem Resizing Columns

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliot
Top achievements
Rank 1
Elliot asked on 15 Dec 2015, 03:37 PM

I have a problem with column resizing.  I am creating a function to auto size all columns taking into account a minimum width.  The problem I am having is that as it resizes the columns eventually a horizontal scrollbar appears and then all columns that are not visible to the right dont get resized.  Is this a bug or how can I get around it?

 Here is the code:

function autoFitColumns(grid) {
    for (var i = 0; i < grid.columns.length; i++) {
        if (!grid.columns[i].hidden) {
            grid.autoFitColumn(grid.columns[i].field);
                     
            var minWidth = grid.columns[i].minWidth;
 
            if (minWidth != undefined && minWidth > grid.columns[i].width) {
                $("#projectGrid .k-grid-header-wrap") //header
                  .find("colgroup col")
                  .eq(i)
                  .css({ width: minWidth });
 
                $("#projectGrid .k-grid-content") //content
                  .find("colgroup col")
                  .eq(i)
                  .css({ width: minWidth });
            }
        }
    }
}

 

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 15 Dec 2015, 07:07 PM
Hi Elliot,

Take a look at this Telerik Kendo UI Dojo which illustrates your autoFitColumns function.  After using the code you provided, I was unable to replicate your described scenario.  Please update my dojo or build a new dojo with your code with the behavior you described.

Regards,
Patrick
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Elliot
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or