Auto Wrap

2 Mar 20221 minute to read

The auto wrap allows the cell content of the grid to wrap to the next line when it exceeds the boundary of the cell width. The Cell Content wrapping works based on the position of white space between words. To enable auto wrap, set the AllowTextWrap property to true. You can configure the auto wrap mode by setting the WrapMode property of TextWrapSettings.

There are three types of WrapMode. They are:

  • Both: Both value is set by default. Auto wrap will be enabled for both the content and the header.
  • Header: Auto wrap will be enabled only for the header.
  • Content: Auto wrap will be enabled only for the content.

When a column width is not specified, then auto wrap of columns will be adjusted with respect to the grid’s width.

In the following example, the WrapMode is set to Content.

@Html.EJS().Grid("AutoWrap").DataSource((IEnumerable<object>)ViewBag.dataSource).AllowTextWrap().Columns(col =>
{

   col.Field("NumberofPatentFamilies").HeaderText("NumberofPatentFamilies").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("Inventor").HeaderText("Inventor").Width("150").Add();
   col.Field("NumberofINPADOCpatents").HeaderText("NumberofINPADOCpatents").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("Mainfieldsofinvention").HeaderText("Mainfieldsofinvention").Width("150").Add();
   col.Field("Active").HeaderText("Active").Width("150").Add();

}).AllowPaging().TextWrapSettings(text => { text.WrapMode(Syncfusion.EJ2.Grids.WrapMode.Content);}).Render()
public IActionResult Index()
{
    var Records = InventorDetails.GetAllRecords();
    ViewBag.DataSource = Records;
    return View();
}