Wrap specific column in Grid

Hello everyone,

I'm working with a table and I'd like to know if it's possible to specify on which columns you want to apply the WrapText option or is it necessarily on all columns without distinction?

Thank you in advance for your answers.
Quentin

1 Reply

PS Pavithra Subramaniyam Syncfusion Team August 23, 2023 06:38 AM UTC

Hi Chaffois Quentin,


In EJ2 Grid, the WrapText option controls whether text within cells should wrap to multiple lines or remain in a single line within all columns without distinction.


However, to achieve different wrapping behavior for different columns, you can use the custom styles by setting the “customAttributes” property for the required column and you could use “white-space: normal” to allow text wrapping for specific columns. This way, only the columns with this style will have text wrapping while others will behave normally.


col.Field("ShipCity").HeaderText("Ship City").CustomAttributes(new { @class = "e-attr" }).Width("150").Add();

 

[style]

.e-grid .e-row .e-rowcell.e-attr {

  height: Auto;

  line-height: 18px;

  overflow-wrap: break-word;

  text-overflow: clip;

  white-space: normal;

  word-wrap: break-word;

}

 

 


https://ej2.syncfusion.com/aspnetmvc/documentation/grid/cell/cell#custom-attributes


Regards,

Pavithra S


Loader.
Up arrow icon