Grid Auto Fit Dynamically

If I enable autofit, I would like the grid to know if it should do autofit or not depending if the grid will look right or not. For example:

Autofit should happen, because too many columns are present, and titles get lost if autofit is not enabled:

Capture.PNG

Autofit should not happen, because the grid columns extend to less than max grid possible width:

imagen_2022-01-17_140425.png

Is it possible to achieve this dynamically to avoid repeating too much code on each grid? Or should I manually do it for each grid?



1 Reply

VN Vignesh Natarajan Syncfusion Team January 28, 2022 06:54 AM UTC

Hi Cesar,  
 
Thanks for contacting Syncfusion support.  
 
Query: “If I enable autofit, I would like the grid to know if it should do autofit or not depending if the grid will look right or not 
 
By default AutoFit enabled columns will adjust and resize its width to fit the widest cell value (i.e.) based on the content maximum value. So it will not adjust based on the Grid width and column count. This is default behavior of Grid.  
 
Since you want to AutoFit Grid component dynamically, we suggest you to manually autofit the column using AutoFitColumnsAsync method of Grid when column count is more. Refer the below documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 


Loader.
Up arrow icon