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

[Solved] Grid doesn't look at column sizes when loaded but does when hiding/showing a column.

1 Answer 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 16 Oct 2014, 07:02 PM
When all columns have set widths on a grid the first time it
loads if the combined width is less than the grid has available the columns
will be resized to fill the space. When a column is shown or hidden the columns
are resized to use their widths that are set from the beginning. I have come up
with a solution to the problem but I was curious of why this happens. When
showing/hiding a column a static width gets set to the table elements of the
combined width of the columns that are shown.

Why does the width get set if it doesn’t happen the first
time the grid loads?

My fix for this is to remove the table widths and allow it
to determine how large it needs to grow inside of its container. 

I find that the results of removing the width on the table
has a better feel to the grid then adding it. Here is an example of this
behavior ( http://dojo.telerik.com/UKiF
) uncomment the $('#grid').find('[role="grid"]').css('width', ''); to
see my fix.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Oct 2014, 02:38 PM
Hello Kyle,

If all columns have explicit widths set, their sum should exceed the Grid width. This is explained in the documentation:

http://docs.telerik.com/kendo-ui/web/grid/appearance#column-widths

The tables' widths are calculated and set to a pixel value after column resizing, hiding and showing, so that the widths of all remaining visible columns remain the same.

Regards,
Dimo
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
Greg
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or