Pages

Monday 22 August 2011

Sharepoint 2010 Calendar View All the events Expanded

By Default SharePoint shows 3 events for any date in the calendar view, if we want to show all the events then we have to use any of the following script for the same.

1)---
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("myFuncAfterLoad");

function myFuncAfterLoad() {
    var oldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4a;

    SP.UI.ApplicationPages.CalendarNotify.$4a = function () {
        oldCalendarNotify4a();
        myFuncToExpandCalendar();
    }
}

function myFuncToExpandCalendar() {
    try {
        var aTags = document.getElementsByTagName('A');
        for (i = 0; i < aTags.length; i++) {

            if ((aTags[i].evtid == "expand_collapse") && (aTags[i].innerText != "collapse")) {
                (aTags[i]).click();
            }
        }
    }
    catch (err) {
        alert(err.message);
    }
}

</script>

******************************************************************
2)
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("myFuncafterLoad");
function myFuncafterLoad(){var OldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4a;SP.UI.ApplicationPages.CalendarNotify.$4a = function (){myFunctoExpandCalendar();OldCalendarNotify4a();}}
function myFunctoExpandCalendar(){try{var aTags=document.getElementsByTagName('A');for(i=0;i<aTags.length;i++){try{if(aTags[i].evtid=="expand_collapse"){aTags[i].click();break;}}catch(err){ alert('Bad Call at' + aTags[i].href);}}}catch(err){alert(err.message);}}</script>

*********************************************************************

3)
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push('WaitForCalendarToLoad');
function WaitForCalendarToLoad()
{  
    SP.UI.ApplicationPages.SummaryItemRenderer.prototype.$2u = function ()
    {
            ULSvSp: ;
            if (!this.$1A_1) this.$1A_1 = 100;
            return this.$1A_1
        }
}</script>

*******************************************************************

4)
<script type="text/javascript">

 _spBodyOnLoadFunctionNames.push('WaitForCalendarToLoad');
function WaitForCalendarToLoad()
{  
    var old$4a = SP.UI.ApplicationPages.CalendarNotify.$4a;
    SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
    {
        old$4a();
        ctrl = SP.UI.ApplicationPages.CalendarInstanceRepository.firstInstance();
        if (ctrl) {
            ctrl.expandAll();
        }
    }
}</script>

********************************************************************

Reference :-- REFERENCE

4 comments:

  1. Hii Deepak

    The above scripts is not working properly so tell me how we can use above scripts properly reply asap

    Thanks
    Deepak chauhan

    ReplyDelete
  2. Hi Deepak,

    Just add a hidden content editor webpart in your calendar page and put any one of the above mentioned script in that content editor webpart, it will work for you. Also make sure you are not using service pack 1 of SP 2010, in that case modify the script as "SP.UI.ApplicationPages.CalendarNotify.$4b" inplace of "SP.UI.ApplicationPages.CalendarNotify.$4a"

    ReplyDelete
  3. Thanks Deepak. after changing to $4b, your scripts worked.

    ReplyDelete

Popular Posts