Tuesday, April 12, 2011

Group Calendar - Default Display

So... as it always seems in my world, I get a lot of "That's great, but what about this?" questions. Getting the Group Calendar to display default resources was fine, but a new requirement to set the default display to month view popped up. Here's how you do it.

Within the code I provided in my previous post, if you kept the code line-for-line and included the jQuery reference, insert this line at the bottom:

MoveView('month', $(el).attr('ctxid'));

If you chose a less sophisticated approach, you could use:

MoveView('month', '[Context ID]');

This will automagically shift your Calendar view to the month view, still displaying your default resources.

Here is the complete code reference:

<script type="text/javascript" src="/Style Library/lib/jQuery.min.js"></script>

<script type="text/javascript">

var el = $(".ms-acal-rootdiv");

var xml = "\u003cEntities Append=\u0022True\u0022 Error=\u0022\u0022 DoEncodeErrorMessage=\u0022True\u0022 Separator=\u0022;\u0022 MaxHeight=\u00223\u0022\u003e\u003cEntity Key=\u0022All Computers\u0022 DisplayText=\u0022All Computers\u0022 IsResolved=\u0022True\u0022 Description=\u0022\u0022\u003e\u003cExtraData\u003e\u003cArrayOfDictionaryEntry xmlns:xsi=\u0022http:\u002f\u002fwww.w3.org\u002f2001\u002fXMLSchema-instance\u0022 xmlns:xsd=\u0022http:\u002f\u002fwww.w3.org\u002f2001\u002fXMLSchema\u0022\u003e\u003cDictionaryEntry\u003e\u003cKey xsi:type=\u0022xsd:string\u0022\u003eResourceMembers\u003c\u002fKey\u003e\u003cValue xsi:type=\u0022xsd:string\u0022\u003e1;#Computer 01;#2;#Computer 02;#3;#Computer 03;#4;#Computer 04;#5;#Computer 05;#6;#Computer 06;#7;#Computer 07;#8;#Computer 08;#9;#Computer 09;#10;#Computer 10;#11;#Computer 11;#12;#Computer 12;#13;#Computer 13;#14;#Computer 14;#15;#Computer 15\u003c\u002fValue\u003e\u003c\u002fDictionaryEntry\u003e\u003cDictionaryEntry\u003e\u003cKey xsi:type=\u0022xsd:string\u0022\u003eSPResourceId\u003c\u002fKey\u003e\u003cValue xsi:type=\u0022xsd:string\u0022\u003e30\u003c\u002fValue\u003e\u003c\u002fDictionaryEntry\u003e\u003cDictionaryEntry\u003e\u003cKey xsi:type=\u0022xsd:string\u0022\u003ePrincipalType\u003c\u002fKey\u003e\u003cValue xsi:type=\u0022xsd:string\u0022\u003eResourceGroup\u003c\u002fValue\u003e\u003c\u002fDictionaryEntry\u003e\u003c\u002fArrayOfDictionaryEntry\u003e\u003c\u002fExtraData\u003e\u003cMultipleMatches \u002f\u003e\u003c\u002fEntity\u003e\u003c\u002fEntities\u003e";



var sel = SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1, $(el).attr('ctxid'));

sel.selectEntities(xml, true);


MoveView('month', $(el).attr('ctxid'));

}

ExecuteOrDelayUntilScriptLoaded(_setDefaultResources, "sp.ribbon.js");
</script>

5 comments:

  1. Hi,
    I have implemented the above code the calendar id navigating to month view but it showing items of mine that is default month view of calendar i need that it should load month view with all resources. Kindly help me...

    ReplyDelete
  2. I liked your article, I will share your article to everyone!!





    ________________________________________________________________________
    WoW gold|Diablo 3 Gold|RS Gold|GW2 Gold

    ReplyDelete
  3. Hi,
    I have implemented the above code the calendar id navigating to month view but it showing items of mine that is default month view of calendar i need that it should load month view with all resources. Kindly help me...


    ____________________________
    Cheap GW2 gold
    gogw2

    ReplyDelete
    Replies
    1. Hi

      Were you able to do a Month view for a group calendar? If yes than can you please help?

      Thanks

      Delete
  4. For this line sel.selectEntities(ret, true); - now I am getting Unable to get property 'selectEntities' of undefined or null reference. It has been working fine before today.

    ReplyDelete