Take the 2-minute tour ×
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 1

up vote 4 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. –  user13813 Dec 28 '12 at 17:31
    
It worked but when i'm on a list and i click item or list it just keeps showing loading... and doesn't stop. Cheers –  naijacoder Sep 8 '13 at 21:06

protected by Community Dec 29 '12 at 10:30

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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