Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

For some reason the scripts I have found on the web (ie: http://social.msdn.microsoft.com/Forums/en-GB/sharepoint2010general/thread/a24da49a-7fc8-47c6-a125-95e4a5b2d095) are not working with a calendar view in a custom list.

All I want to do is auto-expand all in my view when the page loads with some javascript in a CEWP.

Any thoughts or examples of how this has worked?

share|improve this question

1 Answer

up vote 3 down vote accepted

After SP1 for SharePoint 2010 some calendar scripts may stop working. We are using this script to determine when calendar loaded (it includes your expand all requirement):

_spBodyOnLoadFunctionNames.push('WaitForCalendarToLoad');

function WaitForCalendarToLoad() {

    if (typeof SP.UI.ApplicationPages.CalendarNotify.$4a == 'undefined') {
        // post SP1
        var pwold$4b = SP.UI.ApplicationPages.CalendarNotify.$4b;
        SP.UI.ApplicationPages.CalendarNotify.$4b = function () {
            pwold$4b();
            ColourCalendar();
        }
    }
    else {
        // pre SP1
        var pwold$4a = SP.UI.ApplicationPages.CalendarNotify.$4a;
        SP.UI.ApplicationPages.CalendarNotify.$4a = function () {
            pwold$4a();
            ColourCalendar();
        }
    }
} 
function ColourCalendar() {     
    SP.UI.ApplicationPages.CalendarInstanceRepository.firstInstance().expandAll();   
}

It works for me on December 2011 CU.

share|improve this answer
Totally forgot to say this worked! Thanks a TON!!!!!!! – mjrobichaud Jun 29 '12 at 14:00
Where would you run the script? – user9675 Jul 25 '12 at 17:55
Great solution. One question, how would you terminate the CalendarNotify event? I am doing some coloring after the calendar loads, but cannot get the "Loading Calendar..." DIV do disapear. Thanks Darrell – user10730 Sep 14 '12 at 19:03
This worked GREAT! Thanks for posting, it saved the day for me. – Matt Olson Dec 28 '12 at 17:31

protected by Community Dec 29 '12 at 10:30

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.