How to print the Grid using external button in ASP.NET MVC Grid

Hello!
I would like to print a grid with the same characteristic as ToolbarSettings.
However, I want to leave the grid toolBar hidden and print the grid by clicking another button.

Can you help me perform this functionality?

Kind Regards

Junior


1 Reply

DR Dhivya Rajendran Syncfusion Team March 30, 2018 12:43 PM UTC

Hi Carlos, 
  
Thanks for contacting Syncfusion support. 
We have validated your requirement. We have create a sample for your reference. In the below sample we have to print the grid by using external button. Kindly please refer the below sample and code snippet for more information. 
<div> 
   @Html.EJS().Button("printbtn").Content("Print").IsPrimary(true).Render() // render button 
   @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col => 
{ 
    col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); 
    col.Field("ShipCountry").HeaderText("Ship Country").Width("150"). Add(); 
  
}).Render() 
  
</div> 
<script> 
document.getElementById('printbtn').onclick = function () { 
  document.getElementById('Grid').ej2_instances[0].print() // use print() method to print the Grid 
} 
</script> 
  
Regards,
R.Dhivya
 


Loader.
Up arrow icon