SPSRollUp - Attachments

admin posted on March 15, 2009 06:40

To show the attachments icon, you can use the Attachments fields, this field return True or False, if the list item contains an attachment.

To test this and show the icon you can use the next XSLT snippet.

 <xsl:if test="Attachments='True'">
     <img src="/_layouts/images/attachtb.gif" />
 </xsl:if>

Posted in: Tips Tricks  Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SPSRollUp Details View

admin posted on March 15, 2009 06:14

This is a sample XSLT to show a details data view, you can connect a XSLT grid template to this view to show list details. Also you can configure the buttons to take another actions. (In this sample we are using the extended list data to get the actions urls)

The details view show as this:

The XSLT is divided in three sections, the toolbar, the buttons and the rows. 

<?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="html" encoding="UTF-8" indent="yes" />
<!-- Main Template --> <xsl:template match="/Rows"> <xsl:call-template name="Toolbar" /> <!-- Main table --> <table width="100%"
class="ms-listviewtable"
cellspacing="0"
cellpadding="1"
border="0"
style="border-style: none; width: 100%; border-collapse: collapse;"> <tbody> <xsl:for-each select="/Rows/Row"> <xsl:call-template name="DrawRows" /> </xsl:for-each> </tbody> </table> </xsl:template>
<!-- Toolbar --> <xsl:template name="Toolbar"> <table cellSpacing="0"
class="ms-menutoolbar"
cellPadding="0"
border="0"
width="100%"> <tr> <xsl:call-template name="Button"> <xsl:with-param name="url" select="Row/_ItemUrl" /> <xsl:with-param name="option">Display</xsl:with-param> <xsl:with-param name="image">/_layouts/images/detail.gif</xsl:with-param> </xsl:call-template> <xsl:call-template name="Separator" /> <xsl:call-template name="Button"> <xsl:with-param name="url" select="Row/_ItemEdit" /> <xsl:with-param name="option">Edit</xsl:with-param> <xsl:with-param name="image">/_layouts/images/edit.gif</xsl:with-param> </xsl:call-template> <xsl:call-template name="Separator" /> <xsl:call-template name="Button"> <xsl:with-param name="url" select="Row/_ListUrl" /> <xsl:with-param name="option">List</xsl:with-param> <xsl:with-param name="image">/_layouts/images/list.gif</xsl:with-param> </xsl:call-template> <xsl:call-template name="RightFill" /> </tr> </table> </xsl:template>
<!-- Toolbar Button --> <xsl:template name="Button"> <xsl:param name="url" /> <xsl:param name="option" /> <xsl:param name="image" /> <td nowrap="true" class="ms-toolbar"> <table cellspacing="0" cellpadding="1" border="0"> <tbody> <tr> <td nowrap="" style="padding: 3px;" class="ms-toolbar"> <a href="{$url}{sps:SourceParam()}"> <img src="{$image}" border="0" /> </a> </td> <td nowrap="" style="padding: 3px;" class="ms-toolbar"> <a href="{$url}{sps:SourceParam()}"> <xsl:value-of select="$option" /> </a> </td> </tr> </tbody> </table> </td> </xsl:template>


<!-- Toolbar Separator --> <xsl:template name="Separator"> <td>|</td> </xsl:template>
<!-- Toolbar RightFill --> <xsl:template name="RightFill"> <td width="99%" nowrap=""> <img width="1" height="18" alt="" src="/_layouts/images/blank.gif" /> </td> </xsl:template>
<!-- TableRow Template --> <xsl:template name="DrawRows"> <xsl:for-each select="node()"> <xsl:choose> <xsl:when test="starts-with(name(), '_')"> </xsl:when> <xsl:otherwise> <tr class=""> <!-- Icon to send the row --> <td width="165" valign="top" class="ms-formlabel"> <xsl:value-of select="sps:XmlDecode(name())" /> </td> <td valign="top" class="ms-formbody"> <xsl:value-of select="." disable-output-escaping="yes" /> </td> </tr> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template>

</
xsl:stylesheet>

Posted in: Tips Tricks  Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SPSRollUp changing the Grid Pager

admin posted on March 12, 2009 17:08

This is a small xslt snippet to change the pager style, that looks as below. This pager has buttons for first and last page, for previous and next pages and you can establish the desired number of page buttons.

 

The pager template is divided  in small templates for each button, also added a variable to calc the last page. You can change the PageSize and the MaxPageLinks xslt variables.

<?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="html" encoding="UTF-8" indent="yes" />
  
  <xsl:param name="CurrentPage" />
  
  <!-- Customize PageSize & MaxPageLinks -->
  <xsl:variable name="RecordCount" select="count(/Rows/Row)" />
  <xsl:variable name="PageSize" select="10" />
  <xsl:variable name="MaxPagesLinks" select="3" />
  <xsl:variable name="LastPage" select="ceiling($RecordCount div $PageSize)" />
  
  <!-- Main Template -->
  <xsl:template match="/Rows">
    
    <!-- Debug Use 
    <br/>Current Page: <xsl:value-of select="$CurrentPage" />
    <br/>Record Count: <xsl:value-of select="$RecordCount" />
    <br/>Page size: <xsl:value-of select="$PageSize" />   
    <br/>Last Page: <xsl:value-of select="$LastPage" />   
    <br/>
     -->
        
    <!-- Main table -->
    <table width="100%" 
           class="ms-listviewtable" 
           cellspacing="0" 
           cellpadding="1" 
           border="0" 
           style="border-style: none; width: 100%; border-collapse: collapse;">
      <tbody>
        <xsl:call-template name="DrawHeader" />
        <xsl:for-each select="/Rows/Row">
          <xsl:call-template name="DrawRow" />
        </xsl:for-each>
      </tbody>
    </table>

    <!-- Pages Toolbar -->
    <xsl:call-template name="DrawPagesToolbar" />
  </xsl:template>

  <!-- TableHeader Template -->
  <xsl:template name="DrawHeader">
    <tr class="ms-viewheadertr" valign="top">
      <th class="ms-vh2-nofilter ms-vh2-gridview" nowrap="">
        Row
      </th>
      <xsl:for-each select="Row[1]/*">
        <xsl:if test="name()!='_RowNumber'">
          <th class="ms-vh2-nofilter ms-vh2-gridview" nowrap="">        
            <xsl:value-of select="sps:XmlDecode(name())" />        
          </th>
        </xsl:if>
      </xsl:for-each>
    </tr>
  </xsl:template>

  <!-- TableRow Template -->
  <xsl:template name="DrawRow">
    <xsl:choose>
      <!—- LINE INDENTED FOR DISPLAY  --> 
      <xsl:when test="(position() &gt;= 1 + ($CurrentPage - 1) * $PageSize) and 
(position() &lt; (1 + $CurrentPage * $PageSize))"
> <tr class="" > <!-- Icon to send the row --> <td class="ms-vb-title"> <a href="{sps:Event('Select',_RowNumber)}"> <img src="/_layouts/images/exptitem.gif" border="0" /> </a> </td> <!-- All columns except _RowNumber --> <xsl:for-each select="node()"> <xsl:if test="name()!='_RowNumber'"> <td class="ms-vb2"> <xsl:value-of select="." disable-output-escaping="yes" /> </td> </xsl:if> </xsl:for-each> </tr> </xsl:when> </xsl:choose> </xsl:template> <!-- Pages Template --> <xsl:template name="DrawPagesToolbar"> <div class="ms-menutoolbar"> <div class="pagn"> <!-- First and previous page --> <xsl:call-template name="DrawFirstPageButton" /> <xsl:call-template name="DrawPreviousPageButton" /> <xsl:call-template name="DrawSeparatorButton" /> <!-- Draw buttons for pages --> <xsl:for-each select="Row[((position() - 1) mod $PageSize = 0)]"> <xsl:choose> <!-- LINE INDENTED FOR DISPLAY --> <xsl:when test="(position() &gt; ($CurrentPage - ceiling($MaxPagesLinks div 2)) or
position() &gt; (last() - $MaxPagesLinks)) and ((position() &lt;
$CurrentPage + $MaxPagesLinks div 2)
or (position() &lt; 1 + $MaxPagesLinks))"
> <xsl:if test="position()=$CurrentPage"> <xsl:call-template name="DrawSelectedPageButton" /> </xsl:if> <xsl:if test="position()!=$CurrentPage"> <xsl:call-template name="DrawPageButton" /> </xsl:if> </xsl:when> </xsl:choose> </xsl:for-each> <!-- Next and last page --> <xsl:call-template name="DrawSeparatorButton" /> <xsl:call-template name="DrawNextPageButton" /> <xsl:call-template name="DrawLastPageButton" /> </div> </div> </xsl:template> <!-- Pager Button Templates --> <xsl:template name="DrawSeparatorButton"> <span class="pagnSep">|</span> </xsl:template> <xsl:template name="DrawFirstPageButton"> <span class="pagnPrev"> <xsl:if test="position()=1"> <a href="{sps:Event('Page',position())}" class="pagnPrev"></a> </xsl:if> </span> </xsl:template> <xsl:template name="DrawNextPageButton"> <span class="pagnPrev"> <xsl:if test="$CurrentPage &lt; $LastPage"> <a href="{sps:Event('Page',$CurrentPage + 1)}" class="pagnPrev">next »</a> </xsl:if> </span> </xsl:template> <xsl:template name="DrawPreviousPageButton"> <span class="pagnPrev"> <xsl:if test="$CurrentPage &gt; 2 or $CurrentPage = 2"> <a href="{sps:Event('Page',$CurrentPage - 1)}" class="pagnPrev">« prevoius</a> </xsl:if> </span> </xsl:template> <xsl:template name="DrawLastPageButton"> <span class="pagnPrev"> <a href="{sps:Event('Page',$LastPage)}" class="pagnPrev"> »|</a> </span> </xsl:template> <xsl:template name="DrawSelectedPageButton"> <span class="pagnCur"> <xsl:value-of select="position()"/> </span> </xsl:template> <xsl:template name="DrawPageButton"> <span class="pagnLink"> <a href="{sps:Event('Page',position())}" class="pagnLink"> <strong> <xsl:value-of select="position()"/> </strong> </a> </span> </xsl:template> </xsl:stylesheet>

Use the next styles, remember that you can add this to the SPSRollUp.css located in 12 hive, under \LAYOUTS\SPSRollUp directory.

div.pagn, div.pagnBtm {
  padding: 8px 0; 
  display: inline;
  float: left;
  font-size: 93%;
  text-align: center;
  width: 100%;
}


div.pagn .pagnCur
{
  font-weight: bold;
  padding: 0 5px;
}

div.pagn .pagnDisabled {
  color: #999;
  padding: 0px 5px;
  white-space: nowrap;
}

div.pagn .pagnMore, div.pagn .pagnSep {
  padding: 0 2px;
}

div.pagn a, div.pagn a:visited {
  text-decoration: none;
  padding: 6px;
  color: #055d90;
  white-space: nowrap;
}

div.pagn a:hover, div.pagn a:active {
  padding: 5px;
  border: 1px solid #055d90;
  text-decoration: none;
  color: #055d90;
  white-space: nowrap;
  background: #fff;
}

Posted in: Tips Tricks  Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SPSRollUpChart – Task Report

admin posted on December 16, 2008 07:36

Using the previous sample, you can connect the crawled lists with a SPSRollUpChart to show a resume graph with the status of all tasks.

Our goal is show a chart with the status of all tasks in a specified task list. First create a SPSRollUp to select the lists as this

Add a SPSRollUpChart webpart an fill the properties with the same lists and in the fields property write “Status”, because we want get the status of the tasks.

In the CAML query we need write the filter to get the list data using ContentTypeId

<Where>
  <BeginsWith>
    <FieldRef Name="ContentTypeId" />
    <Value Type="Text">[ct:]</Value>
  </BeginsWith>
</Where>

In the SPSRollUpChart XSL we need a chart definition, in this case we want a “Pie Chart” that show the percent of tasks ‘In Progress’, ‘Completed’ and ‘Not Started’

This XSLT count the number of tasks by status.

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

  <xsl:output method="xml" indent="yes" />
<!-- Process Graph --> <xsl:template match="@* | node()"> <xsl:apply-templates /> </xsl:template>



<!-- Pie Chart --> <xsl:template match="Rows"> <graph caption="Tasks Status" decimalPrecision="0" showPercentageValues="1" showNames="1" showValues="1" showPercentageInLabel="1" pieYScale="45" pieBorderAlpha="100" pieRadius="100" animation="1" pieFillAlpha="95" pieBorderColor="FFFFFF"> <xsl:if test="count(//Status[text()='In Progress'])&gt;0"> <set name="In Progress"
value="{count(//Status[text()='In Progress'])}"
color="{sps:GetFcColor()}" /> </xsl:if> <xsl:if test="count(//Status[text()='Completed'])&gt;0"> <set name="Completed"
value="{count(//Status[text()='Completed'])}"
color="{sps:GetFcColor()}" /> </xsl:if> <xsl:if test="count(//Status[text()='Not Started'])&gt;0"> <set name="Not Started"
value="{count(//Status[text()='Not Started'])}"
color="{sps:GetFcColor()}" /> </xsl:if> </graph> </xsl:template> </xsl:stylesheet>

Note that we are checking before write the “set” element if the count return a value greater than zero, we don´t want see any 0%.

Finally we need connect both webparts as in the other example.


Posted in: Tips Tricks  Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5