We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding Title To grid printing

Thread ID:

Created:

Updated:

Platform:

Replies:

129752 Apr 1,2017 06:05 AM UTC Apr 4,2017 06:14 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Andrias Abadi
Asked On April 1, 2017 06:05 AM UTC

Hi,

Is it possible to add title to the data grid when using Grid print function? 
The current grid print only allow to either print the current page / whole grid but both has no setting for title

Jayaprakash Kamaraj [Syncfusion]
Replied On April 3, 2017 10:02 AM UTC

Hi Abadi, 

Thanks for contacting Syncfusion support. 

Yes, it is possible to print the grid with header,title and footer. We have achieved your requirement using BeforePrint event of Grid. In this event, we can append the header, title and footer in Grid(printed grid) using below code example, 


 
 
 
<style> 
    .header { 
        margin-left: 250px; 
        font-family: Calibri; 
        font-size: 35px; 
    } 
</style> 
 
 
 
    @(Html.EJ().Grid<object>("Grid") 
                    .Datasource((IEnumerable<object>)ViewBag.datasource) 
                .ToolbarSettings(toolbar => 
                { 
                    toolbar.ShowToolbar().ToolbarItems(items => 
                    { 
                        items.AddTool(ToolBarItems.PrintGrid); 
                    }); 
                }) 
  .AllowPaging() 
        .Columns(col => 
        { 
            col.Field("OrderID").HeaderText("Order ID").TextAlign(TextAlign.Right).Width(90).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID").Width(90).Add(); 
            col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(80).Add(); 
            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).Format("{0:C}").Add(); 
            col.Field("ShipName").HeaderText("ShipName").Width(150).Add(); 
            col.Field("ShipCountry").HeaderText("ShipCountry").Width(90).Add(); 
        }).ClientSideEvents(eve=>eve.BeforePrint("beforeprint"))) 
<script type="text/javascript"> 
 
    function beforeprint(args) { 
        
        args.element.append(" <label id='lblFooter' runat='server' class='copyrights'>Copyright © 2001 - 2014 Syncfusion Inc. All Rights Reserved</label>"); 
        args.element.prepend("<label id='lblHeader' runat='server' class='header'>Syncfusion</label>");        
 
    } 
</script> 
 
Screenshot: 

 


  
Regards, 

Jayaprakash K. 
 


Andrias Abadi
Replied On April 3, 2017 04:36 PM UTC

Ok cool thanks! 

Jayaprakash Kamaraj [Syncfusion]
Replied On April 4, 2017 06:14 AM UTC

Hi Abadi,  
 
Thanks for the update. 
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;