Navigating multiple calendars in SharePoint

This topic came up over on SharePoint.StackExchange.com, and I thought I’d share here too.

You may want to setup a single page to view multiple calendars. Calendar overlay is a great way to handle this, but what if you want to see these side by side, and let the user navigate the dates in unison, so clicking Next Day will go to the next day, on each calendar.

Two Calendars on a Page

Looking at the above, clicking the day navigation will only update that one calendar web part. Not cool. How do we fix that?

Insert a Snippet App Part, and copy and paste this code into it. It’s a little raw, but it works. Class it up for your brand and site as you need.


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<a href='#' id='newPrevDay'>Previous Day</a>  
<a href='#' id='newNextDay'>Next Day</a>
</div>

<script type="text/javascript">
$(document).ready(function(){

ExecuteOrDelayUntilScriptLoaded(overrideButtons,"SP.UI.ApplicationPages.Calendar.js");

function overrideButtons() {
$("#newPrevDay").click(function() {
$("a[title=\"Previous Day\"]").each(function() {
eval($(this).attr("href"));
});
});

$("#newNextDay").click(function() {
$("a[title=\"Next Day\"]").each(function() {
eval($(this).attr("href"));
});
});
}
});
</script>

Once the code is in, the calendar’s buttons will be hidden and the new buttons will appear, like so:

Calendars with single navigation buttons

 

10 thoughts on “Navigating multiple calendars in SharePoint

Add yours

  1. Hello David, I have a question about lists and calendars: it is possible to make a list from multiple calendars?

    1. Hi Ana,

      It depends on what you hope to do with the list. You can use a search web part and configure it to point to the lists you want, and it’ll return a list. If you want it interactive (add new, edit, delete) then that’ll get a lot more custom. Let me know where you want to go with it.

      Thanks,
      David

      1. I want something interactive, like you mentioned. For example, if I add something in a calendar that information I want it also in the list. It is possible? Can you please give me an idea?
        Thanks a lot!

        1. So you could use the search web part to list the items from a calendar, and after search indexes the newly added data it would appear there. Also, you could look at using a workflow to copy the data form the calendar to a list. Email me david.lozzi at slalom.com what you’re trying to do, what the purpose of the list is and we can figure something out.

  2. I can seem to get this working on sharepoint 2013, is there something i need to change?

      1. I cant seem to get this to work on sharepoint 2013, is there something i need to change?

Leave a Reply

Up ↑

Discover more from David Lozzi

Subscribe now to keep reading and get access to the full archive.

Continue reading