SharePoint 2010 Creating Print list functionality

A requirement which might come often to your ears: How can we simple print the list? And we do not want to have the ribbon nor the quicklaunch, just the list and maybe the logo image. You know SharePoint comes up with lots of css, views and the possibility to use modal dialogs, but anything i tried, it didn’t reflect the desired wishes. Sometimes the search box was still there or the ribbon. So i tried another thing, which worked fine for me and i would like to share.

So i created at first an empty aspx Page with SharePoint Designer, added a dataform webpart and customize the data i want to display. After that i added a button which calls the printer window. The result was an really empty page which only displayed my list items.

But let us go through step by step.

Create an empty aspx Page

In SharePoint Designer i put it below all files. I call it it print.aspx.

Insert Dataform webpart and modify the view

At first you add an empty data view webpart. After that you select the datasource and then you can customize your columns, ordering, filtering and the output.

Add a print button

Just add simple an input tag and use the onclick function with window.print() in order to call the printer window.

If you don’t like the button to appear on the site you can also add a script which calls the printer window immediately
<script type=”text/javascript”>window.print()</script>

Make use of the modal dialog if you like

In order to provide a nice function you can add a custom action to your list, which makes it possible for your users to call a modal dialog which includes the print page. Just go to your list, and select custom actions, add a new custom action. Give a name for it and a nice logo and add to the navigate to url field the following code:

javascript:SP.UI.ModalDialog.showModalDialog({ url: “../../print.aspx”, title: “I Like to Print”});

Well you should insert your url and it can be used by the custom action.

Function is ready to go

Do you have any ideas how to exclude the button from printing result? If you know a smart solution, i would like to hear. I know there are some solutions out there where you make use of some more javascript, but they always open a new page. Is it possible to make it without opening a new page?

I hope in SharePoint 2013 there is a better way – a out of the box functionality to print lists 🙂

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.