I have a Kendo Grid and I want to set the minimum width of some columns to the size of their content.
Any ideas on how to do that?
Thank you.
1 Answer, 1 is accepted
1
Accepted
Stoyan
Telerik team
answered on 15 Oct 2021, 11:34 AM
Hi Stavros,
To set the width of a column based on the content inside, the autoFitColumnsmethod of the grid can be utilized which adjusts the width of the specified columns to fit the entire content. Please bear in mind if no parameters are passed to the method, it will resize all of the columns.
I've prepared a short StackBlitz demo that demonstrates the wanted behavior:
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/.
As in the code snippet, it is not visible where the autoFitColumns method is called. When retrieving data asynchronously, it has to be made sure that the data is available on the client.
I've created a short StackBlitz demo, that shows the autoFitColumns method working with async retrieved data: