Add Print Button to List/Library form in SharePoint 2013 using jQuery


To Add the Print button, Open SharePoint list in browser, go to List Tab -> Customize List Tab -> Form Web Parts and then click on Default Display Form as shown in the fig below:




Then in this page, click on Add a Web Part 
and then from the web part Categories select Media and Content and then select Content Editor web part as shown in the fig below:



Then in the Content Editor web part click on Click here to add new content, then click on FORMAT TEXT -> Markup -> Edit Source as shown in the fig below:



Then in the HTML Souce, Add the below code as shown below:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script><script>

$(document).ready(function() {
  $('.printList').click(function() { 
  window.print(); 
  return false; 
  });
});</script>

<style> 
.printList{ 
    color:#666666; 
    font-weight:bold; 
    cursor:pointer; 
}
.printList:hover{ 
color:#333333; 
font-weight:bold; 
cursor:pointer; 
}
</style>
<button class="printList">Print This Item</button>



No comments:

Post a Comment