SPSRollUp Dropdown Recipe
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.