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 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  (very basic example)

<?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()"> <!-- Graph --> <SPSCalendar> <xsl:apply-templates /> </SPSCalendar> </xsl:template> <!-- Each row --> <xsl:template match="Row"> <!-- Put here your fields --> <SPSCalendarItem StartDate="{StartDate}" EndDate="{DueDate}" Title="{Title}" /> </xsl:template> </xsl:stylesheet>

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

<SPSCalendar xmlns:sps="http://schemas.spsprofessional.com/WebParts/SPSXSLT">
  <SPSCalendarItem StartDate="2008-03-25T00:00:00Z" 
EndDate="2008-04-09T00:00:00Z" Title="Task in Project One" /> <SPSCalendarItem StartDate="2008-02-25T00:00:00Z"
EndDate="2008-03-25T00:00:00Z" Title="Task in Project Two" /> <SPSCalendarItem StartDate="2008-03-25T00:00:00Z"
EndDate="2008-03-28T00:00:00Z" Title="New Customers Letter" /> </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. 

 

Sample XSLT  (Full Example)

Use ISO Dates

<?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()"> <!-- Calendar in Week format --> <SPSCalendar ViewType="week"> <xsl:apply-templates /> </SPSCalendar> </xsl:template> <!-- Each row --> <xsl:template match="Row"> <!-- Put here your fields --> <xsl:element name="SPSCalendarItem"> <xsl:if test="string(StartDate)"> <xsl:attribute name="StartDate"> <xsl:value-of select="StartDate" /> </xsl:attribute> </xsl:if> <xsl:if test="string(DueDate)"> <xsl:attribute name="EndDate"> <xsl:value-of select="DueDate" /> </xsl:attribute> </xsl:if> <xsl:attribute name="Title"> <xsl:value-of select="Title" /> </xsl:attribute> <!-- Url to go --> <xsl:attribute name="DisplayFormUrl"> <xsl:value-of select="substring-before(_ItemUrl,'?')" /> </xsl:attribute> <!-- Required to go to Url --> <xsl:attribute name="ItemID"> <xsl:value-of select="_ItemId" /> </xsl:attribute> </xsl:element> </xsl:template> </xsl:stylesheet>