Completed
Last Updated: 15 Nov 2021 12:51 by ADMIN
Christian
Created on: 30 Mar 2021 17:37
Category: Grid
Type: Feature Request
42
Autofit column widths on data load

I want the grid to be able to resize all the columns (or only certain columns) to fit their data, when the data loads, without the user having to double click the border between them.

---

ADMIN EDIT

Automatic application of the auto fitting will come with a flicker, and that's why it was declined as a feature originally. In Blazor we have a detachment between code and when exactly something is rendered. So, we have no way to trigger the resizing logic immediately after the columns content is rendered. The events that are available will cause a flicker and can cause a performance hit - both for the browser and also by raising StateChanged multiple times.

Another caveat is how would this be exposed for configuration - should it work for all columns at once, or only for certain columns (how to control for which ones), how to control which data-related events should invoke this logic (or should it happen super often on any event). Exposing such configuration is likely to lead to a property hell type of situation.

Perhaps a way to get this would be to provide API on the grid to invoke that functionality that you can call as required by your logic and UX: https://feedback.telerik.com/blazor/1513384-programmatically-invoke-fit-to-width-functionality-for-the-grid-columns.

Nevertheless, we will keep this open to monitor for feedback, what is requested, interest and how people would want it exposed. Leave your comments and preferences here.

---

5 comments
ADMIN
Svetoslav Dimitrov
Posted on: 15 Nov 2021 12:51

Hello all,

You can achieve the desired behavior by using the approach from the Autofit all Grid columns on the initial load knowledge-based article. 

That being said, I am marking this Feature Request as "Completed" with the knowledge-based article.

Regards,
Svetoslav Dimitrov
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/.

Gerhard
Posted on: 22 Apr 2021 10:23

If we can get this https://feedback.telerik.com/blazor/1513384-programmatically-invoke-fit-to-width-functionality-for-the-grid-columns at least there a way to sensibly size columns.

I will add suggestions/requests there.

Joeri
Posted on: 31 Mar 2021 09:38

Hi Marin,

Thanks for the clarification. Then indeed that won't do any good. I really hope you guys can come up with something, our users are really missing this functionality in the grids :) 

ADMIN
Marin Bratanov
Posted on: 31 Mar 2021 09:34

Thank you for the suggestion, Joeri.

A problem with that is that setting the Width parameter of the column must render that setting to the colgroup element which has a different meaning - it is a plain CSS rule where any other column width goes (say, explicit values in pixels). Even if the grid were to look for it, it would then have to await rendering, then invoke calculations, and set the width in pixels, which will flicker, and will fire StateChanged.

 

Regards,
Marin Bratanov
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/.

Joeri
Posted on: 31 Mar 2021 08:59

Hello,

I was also looking for this exact feature after 2.23.0 was released. A suggestion I have about the configuration part is to use the Width="auto" on the GridColumn component. So if I have a grid with 2 columns, and I want to have one of the columns to be autofitted on loading, then I set the Width parameter of the GridColumn to "auto". Then the component knows on data load which columns needs to be autofitted.