Home> SPSRollUpCalendar - WebPart

SPSRollUpCalendar - WebPart

Included in version 2 of SPSRollUp there is a new webpart to roll up data and show it using the SharePoint calendar view.

SPSRollUpCalendar has a similar operation to the SPSRollUp and SPSRollUpChart, and this means that it tracks sites and lists collecting information, the collected data is transformed using XSLT to generate XML as SPSRollUpChart does. The result XML is a description of the events to show in a calendar view.

The XSLT must generate a collection of SPSCalendarItems

By example the rollup output

<Rows>
  <Row>
    <_RowNumber>0</_RowNumber>
    <Title>Task in Project One</Title>
    <DueDate>2008-04-09T00:00:00Z</DueDate>
    <StartDate>2008-03-25T00:00:00Z</StartDate>
  </Row>
  <Row>
    <_RowNumber>1</_RowNumber>
    <Title>Task in Project Two</Title>
    <DueDate>2008-03-25T00:00:00Z</DueDate>
    <StartDate>2008-02-25T00:00:00Z</StartDate>
  </Row>
  <Row>
    <_RowNumber>2</_RowNumber>
    <Title>New Customers Letter</Title>
    <DueDate>2008-03-28T00:00:00Z</DueDate>
    <StartDate>2008-03-25T00:00:00Z</StartDate>
  </Row>
</Rows>

Important Note: The dates in results are in ISO format.

is transformed using the next XSLT (you can copy/paste this sample as base for your calendars) 

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:sps="http://schemas.spsprofessional.com/WebParts/SPSXSLT">

  <xsl:output method="xml" indent="yes" />
  
  <xsl:template match="@* | node()">
    <!-- Our Calendar View Calendar -->
    <SPSCalendar ViewType="week">
      <xsl:apply-templates />
    </SPSCalendar>
  </xsl:template>

  <!-- Each row -->
  <xsl:template match="Row">
    <!-- Put here your fields -->
    <xsl:element name="SPSCalendarItem">
      
      <!-- StartDate -->
      <xsl:if test="string(StartDate)">
        <xsl:attribute name="StartDate">
          <xsl:value-of select="sps:FormatDateTime(StartDate,'s')" />
        </xsl:attribute>
      </xsl:if>

      <!-- EndDate -->
      <xsl:choose>
        <xsl:when test="string(DueDate)">
          <xsl:attribute name="EndDate">
            <xsl:value-of select="sps:FormatDateTime(DueDate,'s')" />
          </xsl:attribute>
        </xsl:when>        
        <xsl:otherwise>
          <!-- If no DueDate specified use StartDate -->
          <xsl:if test="string(StartDate)">
            <xsl:attribute name="EndDate">
              <xsl:value-of select="sps:FormatDateTime(StartDate,'s')" />
            </xsl:attribute>
          </xsl:if>
        </xsl:otherwise>        
      </xsl:choose>

      <!-- Title -->
      <xsl:attribute name="Title">
        <xsl:value-of select="Title" />
      </xsl:attribute>
      
      <!-- DisplayFormUrl -->
      <xsl:attribute name="DisplayFormUrl">
        <xsl:value-of select="substring-before (_ItemUrl, '?' )" />
      </xsl:attribute>
      
      <!-- ItemID -->
      <xsl:attribute name="ItemID">
        <xsl:value-of select="_ItemId" />
      </xsl:attribute>
      
      <!-- BackgroundClassName -->
      <xsl:attribute name="BackgroundColorClassName">
        <xsl:value-of select="sps:GetCalColor()" />
      </xsl:attribute>
    </xsl:element>

  </xsl:template>
</xsl:stylesheet>

And the final result is the next XML that is a calendar definition

<SPSCalendar ViewType="week" xmlns:sps="http://schemas.spsprofessional.com/WebParts/SPSXSLT">
  <SPSCalendarItem StartDate="2008-12-01T00:00:00" 
                   EndDate="2008-12-16T00:00:00" 
                   Title="Task 1" 
DisplayFormUrl="/spsrollup/Lists/Tasks/DispForm.aspx" ItemID="10" BackgroundColorClassName="SPSCal_Aquamarine" /> <SPSCalendarItem StartDate="2008-12-09T00:00:00" EndDate="2008-12-13T00:00:00" Title="Task 2"
DisplayFormUrl="/spsrollup/Lists/Tasks/DispForm.aspx"
                   ItemID="11" 
                   BackgroundColorClassName="SPSCal_Teal" />
  <SPSCalendarItem StartDate="2008-12-21T00:00:00" 
                   EndDate="2008-12-31T00:00:00" 
                   Title="Task 3" 
                   DisplayFormUrl="/spsrollup/Lists/Tasks/DispForm.aspx" 
                   ItemID="12" 
                   BackgroundColorClassName="SPSCal_ForestGreen" />
 
 (Other tasks)
</SPSCalendar>
 

Which render view is

This allows us to have full control over how the calendar is drawn as well as the actions to be carried out when we select the various items which are part of it.

Additionally it has been added a html (CSS) stylesheet called SPSCalendar.css listed in the /_layouts/SPS/SPSCalendar.css directory; This is loaded each time you implement SPSRollUpCalendar and it can be used to establish your own styles.

The XML that defines a calendar is given by the following syntax.

 

SPSCalendar XML definition

 

SPSCalendar - Element for the calendar definition

Attributes:

ViewType - (string) - The type can be one of following strings: "month", "week" or "day"

Contains:

SPSCalendarItem (min 0 max n)
 

SPSCalendarItem Attributes - Element for calendar event definition

Attributes:

BackgroundColorClassName - (string) - The background color class name. 
Description  - (string) - String that represents the description of the calendar item. 
DisplayFormUrl  - (string) - Value that represents the display form URL of the calendar item. 
EndDate  - (string) - The date time value that represents the end date of the calendar item.  (ISO format)
hasEndDate - (boolean) - Value that indicates whether the calendar item has an end date. 
IsAllDayEvent  - (boolean) - Value that indicates whether the calendar item is an all-day event. 
IsRecurrence  -  (boolean) - Value that indicates the recurrence of the calendar item. 
IsRecurrenceException  - (boolean) - That indicates whether this is an exception to a recurring calendar event. 
ItemID  - (string) - Value that represents the ID of the calendar item. 
Location  - (string) - Value that represents the location of the calendar item. 
StartDate  - (string) The date/time value that represents the start date of the calendar item.  (ISO format)
Title - (string) - Value that indicates the title of the calendar item.