Displaying the HTML content

25 Feb 20221 minute to read

The HTML tags can be displayed in the Grid header and content by enabling the DisableHtmlEncode property in Column.

@Html.EJS().Grid("HTMLEncode").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
  col.Field("OrderID").HeaderText("<span> Order ID </span>").Width("120").DisableHtmlEncode(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
  col.Field("CustomerID").HeaderText("<span> Customer ID </span>").Width("150").DisableHtmlEncode(true).Add();
  col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
  col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
  col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();

}).AllowPaging().PageSettings(page => { page.PageCount(5);}).Render()
public IActionResult Index()
{
    var Order = OrderDetails.GetAllRecords();
    ViewBag.DataSource = Order;
    return View();
}