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

autoFitColumn doesn't work like double-click column separater

3 Answers 303 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gerry
Top achievements
Rank 1
Veteran
Gerry asked on 19 Aug 2020, 08:38 PM

When you float your mouse cursor over the line that separates two columns in a grid (sometimes) a cursor comes up, it looks like a left arrow, two vertical bars and a right arrow.

If you then double click, Kendo now does a nice job of auto fitting the column (on the left of the special cursor). This behavior is different from the normal autoFitColumn call, which does not account for sort and filter icons nor the size of the column header.

How can I get the same auto-fit programmatically?

[I am unable to get a screenshot that includes the cursor because my Adesso keyboard has no proper print screen button. Every app I have tried requires special mouse activity, causing the special icon to disappear before I can take the screenshot]

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 21 Aug 2020, 12:14 PM

Hi Gerry,

I can confirm that the resize handle of the grid internally calls the autoFitColumn method. Therefore, the same functionality should be observed in both cases.

The only difference might be due to the fact that the column is auto-fitted before the actual icon has been rendered. For instance, in the example below, a setTimeout function is used to demonstrate the same:

https://dojo.telerik.com/uHIJinUp

I hope you find this helpful.

 

Kind regards,
Tsvetomir
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Gerry
Top achievements
Rank 1
Veteran
answered on 21 Aug 2020, 04:17 PM
Thanks. So I guess whenever the user sorts I might need to resize the column sorted on.
0
Tsvetomir
Telerik team
answered on 25 Aug 2020, 10:24 AM

Hi Gerry,

Yes. The default functionality of the sorting does not resize the column. It would be unexpected if the sort function resizes a column of the grid. This would lead to weak cohesion and coupling of different segments of the code. 

Therefore, if you would like to resize a column after sorting, this has to happen manually. Perhaps, in the Sort event of the grid.

 

Kind regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Gerry
Top achievements
Rank 1
Veteran
Answers by
Tsvetomir
Telerik team
Gerry
Top achievements
Rank 1
Veteran
Share this question
or