Add a title to the header when using Grid print function

17 Feb 20222 minutes to read

You can add your title in the header through an beforePrint event. With the help of this event you can add your title element as you want.

<div id="GridParent">
    <ejs-grid id="Grid" dataSource="@ViewBag.DataSource" toolbar="@(new List<string>() { "Print" })" beforePrint="beforePrint" height="315" allowPaging="true">
            <e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
            <e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120"></e-grid-column>
            <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" editType="numericedit" width="120"></e-grid-column>
            <e-grid-column field="ShipCity" headerText="Ship City" width="120"></e-grid-column>
            <e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>

    function beforePrint(args) {
    var div = document.createElement("Div")
        div.innerHTML = "Title here" = 'center'; = 'red'; = '10px 0'; = '25px';
        args.element.insertBefore(div, args.element.childNodes[0]);
public IActionResult Index()
    var Order = OrderDetails.GetAllRecords();
    ViewBag.DataSource = Order;
    return View();