Does the autofit function not consider the contents of merged lines?

Hi,

I have grid, all columns are merged to display prompt information in the last row.

  Default Style:


After click auto fit, the "Code“ column width is too large:


I think the autofit function cannot consider the contents of merged lines.

Code for FYI:



I make a little sample:

https://stackblitz.com/edit/angular-zqtz5l-test?file=app.component.html


3 Replies

SK Sujith Kumar Rajkumar Syncfusion Team July 14, 2021 08:11 AM UTC

Hi Lorryl, 
 
Greetings from Syncfusion support. 
 
Based on the provided information we could understand that the problem you are reporting is that the auto fit is making the column width large if a large text content is present in one of its cell. We would like to inform you that the autoFitColumns method of the Grid resizes the columns to fit its widest cell’s content without wrapping. Even if column span is set each column cell will be aligned according to the auto fitted width. This is the default behavior of the auto fit functionality which is also mentioned in the below documentation link, 
 
 
And based on the shared sample, the ‘EmployeeID’ column will set its width based on its widest cell content as shown in the below image, 
 
 
 
So please let us know your exact requirement with pictorial demonstration(if possible) based on which we will validate further and provide the details. 
 
Regards, 
Sujith R 



LO lorryl July 14, 2021 09:20 AM UTC

I don't want the autofit function to consider the merged column content. I think there are two solutions:


1. After using the grid autofit function, I adjust the width of the "Employee" column separately, but I don't know how to calculate the column width excluding the combined column content.


2. Use other methods to display a whole line without affecting auto fit





SK Sujith Kumar Rajkumar Syncfusion Team July 15, 2021 09:50 AM UTC

Hi Lorryl, 
 
As mentioned in the previous update, the autoFitColumns method of the Grid resizes the columns to fit its widest cell’s content without wrapping. This is the default behavior of the auto fit functionality of the Grid.  
 
However, you can use the autoWrap functionality of the Grid which allows the cell content to be wrapped to the next line when it exceeds the column width. But even with that calling the autoFitColumns will set the column width based on the widest cell content. And if you set column span to this cell, it will not be wrapped to the next line until it reaches the end of the column span. So for your requirement we suggest you to use auto wrap functionality without autoFit and column span. 
 
More details on auto wrap can be checked in the below documentation link, 
 
 
But, we are still not able to clearly understand your exact requirement from the provided information. So if you do not wish to use the above suggested solution, then please let us know why you are setting column span for a large text content but then need to auto fit it not considering the entire cell width. 
 
Regards, 
Sujith R 


Loader.
Up arrow icon