3

I'm trying to have my events list display as a calendar view in a Sharepoint-hosted app written using JavaScript and the Client Side Object Model.

Here's the code I'm using.

From Default.aspx:

<WebPartPages:WebPartZone runat="server" FrameType="None" ID="CalendarWebPart" />

From the Elements.xml associated with Default.aspx:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages">
<File Path="Pages\ClientWebPart.aspx" Url="Pages/ClientWebPart.aspx" ReplaceContent="TRUE" />
<File Path="Pages\Default.aspx" Url="Pages/Default.aspx" ReplaceContent="TRUE">

  <View
List="Lists/Paid Time Off List"
BaseViewID="2"
WebPartZoneID="CalendarWebPart"
WebPartOrder="1"
Type="CALENDAR"
Scope="Recursive"
RecurrenceRowset="TRUE">
    <![CDATA[
      <webParts>
          <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
              <metaData>
                  <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                  <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
              </metaData>
              <data>
                  <properties>
                      <property name="Title" type="string">My Calendar</property>
                      <property name="InplaceSearchEnabled" type="bool">False</property>
                      <property name="ShowToolbarWithRibbon" type="bool">False</property>
                  </properties>
              </data>
          </webPart>
      </webParts>
  ]]>
  </View>

</File>

I see this even though BaseViewID="2" definitely is my calendar view:

List View

I expected a calendar view like this (this is the calendar for my events list, from /Lists/Paid Time Off List/Calendar.aspx):

Calendar View'

Any idea why the Calendar view isn't working inside of my webpart, but works fine when I go to the page for the calendar view?

Note: My code is based on the code found here: http://www.greggalipeau.com/2013/12/25/adding-list-views-to-sharepoint-2013-apps/

Maybe this is a potential solution, but I don't understand the process this author is proposing: http://cameron-verhelst.be/blog/2013/03/24/sharepoint-2010-calendar-view-on-xsltlistviewwebpart/

2 Answers 2

1

You should also check the properties of your view. You reference the version 14.0.0.0 which is only suitable for SharePoint 2010 for SharePoint 2013 you need to change these to 15.0.0.0. This:

<type 
     name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,
           Microsoft.SharePoint,Version=14.0.0.0,
           Culture=neutral,PublicKeyToken=71e9bce111e9429c" />

needs to be changed to:

<type 
     name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,
           Microsoft.SharePoint,Version=15.0.0.0,
           Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
0

author from the linked blogpost here.

My solution was to use a different class (ListViewWebPart insteaad of XSLTListViewWebPart). Where I did it in code, you can do it in CAML/XML:

http://blogs.edwardwilde.com/2009/11/16/how-to-add-a-list-view-web-part-to-onet-xml-or-your-elements-manifest/

<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
    <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
    <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
    <Title>Pending Registrations</Title>
</WebPart>

As you can see, the XML is a little different, so you'll have to look around how to set the view etc. on this type of webpart. Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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