SPSRollUp - Drop Down Box Recipe

admin posted on August 23, 2008 14:20

In a blank page insert two SPSRollUp webparts.
Edit the properties in the first webpart and select any list, in the fields property write “Title”

In the XSL paste the next snippet; This snippet fills a drop down box with the titles of all crawled data

<?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>"
exclude-result-prefixes="sps"> <xsl:output method="html" /> <xsl:param name="CurrentRow" /> <xsl:template match="/"> <script type="text/javascript"> function combo_onchange(oSelect) { if(oSelect.selectedIndex != -1) { var selected = oSelect.options[oSelect.selectedIndex].value; <xsl:value-of select="sps:EventJS('Select','selected')" /> } } </script> Select a value <select id="a1" name="combo" onchange="javascript:combo_onchange(this);" class="ms-input"> <option value="" /> <xsl:for-each select="Rows/Row"> <xsl:sort select="Title" /> <xsl:element name="option"> <xsl:attribute name="value"> <xsl:value-of select="_RowNumber" /> </xsl:attribute> <xsl:if test="_RowNumber=$CurrentRow"> <xsl:attribute name="selected" /> </xsl:if> <xsl:value-of select="Title" /> </xsl:element> </xsl:for-each> </select> </xsl:template> </xsl:stylesheet>

When a value is selected the JavaScript embedded in the XSL "combo_onchange" send the selected value using the row provider interface.

Note: SPSRollUp send a full row of data, we can show only the title in the drop down box, but if we have more fields in the properties all fields are sent.

Apply changes in the first webpart; You should see the drop down box with the titles

In the second webpart use the same list and in the fields property write "Title,CreatedBy", enable the Debug query and in the CAML query use the following query.

<Where>
  <Eq>
    <FieldRef Name="Title" />
    <Value Type="Text">[FromCombo:]</Value>
  </Eq>
</Where>

This query introduce a variable called "FromCombo". "FromCombo" is the value that we need to perform the query. To get this value we need connect this webpart with a provider webpart.

First apply changes, you should see this

Note: We can give a default value to the variable "FromCombo" , to do it, put the default value after colons.

Now connect both webparts

You can connect each field in the provider row, with the desired value in the consumer webpart. Skip the _RowNumber and connect the "Title" field with the "FromCombo" variable.

Finally you can view the result when you select a value in the drop down box.


Posted in: Tips Tricks  Tags:

Be the first to rate this post

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

SPSRollUp 2.0 Beta - TaskCamp

admin posted on July 3, 2008 17:39

We are developing an application for a customer using SPSRollUp (Beta 2), our customer want a site with some features that seem like BaseCamp site, BaseCamp is a well know Project Management web application.

Using SPSRollUp our customer can aggregate data from sub-projects and show all tasks status in an only view. But he want a special view that he likes specially, this view show pending tasks whit delayed days and coming tasks with the remaining days.

These views shows as:

          

To do it we are using two SPSRollUp webparts, the first one for the Late view, the CAML query is:

<Where>
  <And>
    <Lt>
      <FieldRef Name="DueDate" />
      <Value Type="DateTime">
        <Today />
      </Value>
    </Lt>
    <Neq>
      <FieldRef Name="Status" />
      <Value Type="Choice">Completed</Value>
    </Neq>
  </And>
</Where>

This query show tasks not completed and with due date lower than today. (Coming tasks query is similar, with due date greater than today)

The next XML is for the late view, note the new SPS function DateDiff() (included in 2.0 Beta)

<?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" indent="yes" />
  <!-- Header -->
  <xsl:template match="Rows">
    <h1 style="font-size:1em;background-color:#CC0000;border-bottom:1px 
solid #CC0000;color:#FFFFFF;margin:0pt 0pt 4pt"
>Late</h1> <!-- Draw Rows --> <xsl:for-each select="Row">
      <!-- Sort dates (important)Tip: Use ISO dates to sort dates in XML -->
      <xsl:sort select="DueDate" order="descending" />
      <xsl:call-template name="DrawRow" />
    </xsl:for-each>
  </xsl:template>
  <!-- Row Table Template -->
  <xsl:template name="DrawRow">
    <div style="border-bottom:1px solid #E0E0E0;padding:4px 0pt 4px 3px;">
      <div style="color:#CC0000;font-family:verdana;font-size:10px;padding:0pt 0pt 3px;">
        <strong>
          <xsl:value-of select="sps:DateDiff('d',DueDate,sps:TodayIso())" /> days ago 
</strong>
(<xsl:value-of select="sps:FormatDateTime(DueDate,'dddd, dd MMM')" />)</div> <div style="font-weight:bold;padding:0pt 5pt 6px;"> <xsl:value-of select="Title" /> </div> </div> </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

SQL to CAML query tool

admin posted on June 27, 2008 12:44

Test our online tool to create CAML queries easily, try www.spsprofessional.com/sqlcaml.aspx


Posted in: Tips Tricks  Tags:

Be the first to rate this post

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

SPSRollUp - Showing image indicators

admin posted on June 13, 2008 14:35

You can replace texts with custom images using the XSL. First you need load the desired images in the /_layouts/images of your server, after load you can use this images from XSL. Here is a little sample where the status of the tasks are replaced  with flag images.

The XSL is the same used in the Task Status example, where we are add a <xsl:choose> in order to select the image:

<?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" />
  <xsl:template match="/">
    <table width="100%">
      <tr>
        <th>Task</th>
        <th>Due date</th>
        <th>Status</th>
      </tr>
      <tbody>
        <xsl:for-each select="Rows/Row">
          <tr>
            <td>
              <a href="{_ItemUrl}">
                <xsl:value-of select="Title" />
              </a>
            </td>
            <td>
              <!-- Show the DueDate -->
              <p style="color:#ff0000;text-align:right">
                <xsl:value-of select="substring-before(DueDate,' ')" />
              </p>
            </td>
            <td class="ms-vb" width="5%" style="padding-bottom: 3px">
<!-- Show the Image -->
<xsl:choose> <xsl:when test="Status='Completed'"> <img src="/_layouts/images/flag_green.png" /> </xsl:when> <xsl:when test="Status='In Progress'"> <img src="/_layouts/images/flag_orange.png" /> </xsl:when> <xsl:when test="Status='Deferred'"> <img src="/_layouts/images/flag_blue.png" /> </xsl:when> <xsl:when test="Status='Not Started'"> <img src="/_layouts/images/flag_red.png" /> </xsl:when> <xsl:otherwise> <img src="/_layouts/images/flag_black.png" /> </xsl:otherwise> </xsl:choose> </td> </tr> </xsl:for-each> </tbody> </table> </xsl:template> </xsl:stylesheet>

Posted in: Tips Tricks  Tags:

Currently rated 5.0 by 1 people

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