Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SharePoint list that has several records. One field in the list uses SPServices to query possible values in another list during data entry (essentially a lookup).

I created a view and am looking at customizing the XSLT so that I only show records where the lookup field mentioned above appears more than once. For example, say I have a simple list:

ID    Location
===============
1     123
2     123
3     456

I want to create a view where the only items that are displayed are ID#1 and #2 because the location appears multiple times.

If a new item (#4) is added and it contains a location of 123, #4 should now appear in this view, but #3 should still be excluded.

ID    Location
===============
1     123
2     123
3     456
4     123

Instead, if #4 had a location of 456, all entries should display (preferrably grouped) in the view.

ID    Location
===============
1     123
2     123
3     456
4     456

So I am assuming that 1) I need to do a count for each location, 2) assign a count for each entry in the list and 3) filter on the count field where greater than one. I am just not sure where to start here.

I appreciate the help.

share|improve this question
    
Could you include the XSLT that you have written so far? Thanks! –  Marcus Rickert Nov 2 '13 at 1:17
    
I'm a little confused since the code that you mentioned is not valid XSLT or XPath. –  Marcus Rickert Nov 7 '13 at 9:18
    
I added Conditional Formatting on the row, which hides the rows succesfully. But I would also like to hide the header as well. The condition I am using is the following: CONDITION: count(/dsQueryResponse/Rows/Row[@Location1=$thisNode/@Location1])<2 FORMATTING: Display:None –  JuanTrev Nov 7 '13 at 21:00

1 Answer 1

up vote 0 down vote accepted

I am not sure why it is working all of a sudden (maybe my own syntax), but I was able to hide group headers with XSLT by wrapping the td tag in a xsl:if block.

 <xsl:template name="GroupHeader" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="fieldtitle" />
    <xsl:param name="fieldname" />
    <xsl:param name="group" select="."/>
    <xsl:param name="fieldtype" />
    <xsl:param name="groupid" />
    <xsl:param name="groupindex" />
    <xsl:param name="groupindex2" />
    <xsl:param name="imagesrc" />
    <xsl:param name="alttext" />
    <xsl:param name="altname" />
    <xsl:param name="RowCount" select="1"/>
    <xsl:param name="Collapse"/>
<tbody id="titl{$ViewCounter}-{$groupindex}{$groupindex2}" groupString="{@*[name()=concat($fieldtitle, '.urlencoded')]}">
    <xsl:if test="$Collapse">
        <xsl:attribute name="style">display:none</xsl:attribute>
  </xsl:if>
  <tr id="group{$groupid}">
  <!-- CHANGE HERE -->
  <xsl:if test="$RowCount &gt; 1">
 <td colspan="100" nowrap="nowrap" style="height: 19px">
        <xsl:attribute name="class">
            <xsl:choose>
                <xsl:when test="$groupid='0' or $groupid='9'">ms-gb</xsl:when>
                <xsl:otherwise>ms-gb2</xsl:otherwise>
            </xsl:choose>
      </xsl:attribute>
        <xsl:choose>
            <xsl:when test="$groupid='0' or $groupid='9'">
        </xsl:when>
            <xsl:when test="$groupid='1'">
          <img src="/_layouts/images/blank.gif" alt="" height="1" width="10"/>
        </xsl:when>
            <xsl:otherwise>
          <img src="/_layouts/images/blank.gif" alt="" height="1" width="20"/>
        </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
            <xsl:when test="$NoAJAX or $InlineEdit">
          <a href="javascript:" onclick="javascript:ExpCollGroup('{$ViewCounter}-{$groupindex}{$groupindex2}', 'img_{$ViewCounter}-{$groupindex}{$groupindex2}',event, true);return false;">
            <img src="{$imagesrc}" border="0" alt="{$alttext}" id="img_{$ViewCounter}-{$groupindex}{$groupindex2}" />
                <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$fieldname" />
          </a>
        </xsl:when>
            <xsl:otherwise>
          <a href="javascript:" onclick="javascript:ExpCollGroup('{$ViewCounter}-{$groupindex}{$groupindex2}', 'img_{$ViewCounter}-{$groupindex}{$groupindex2}',event, false);return false;">
            <img src="{$imagesrc}" border="0" alt="{$alttext}" id="img_{$ViewCounter}-{$groupindex}{$groupindex2}" />
                <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$fieldname" />
          </a>
        </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="$fieldname"> : </xsl:if>
        <xsl:choose>
            <xsl:when test="$fieldtype='Number' or $fieldtype='Currency'">
          <xsl:value-of select="@*[name()=$fieldtitle]" disable-output-escaping="yes"/>
        </xsl:when>
            <xsl:when test="$fieldtype ='DateTime'">
          <xsl:value-of select="@*[name()=concat($fieldtitle, '.groupdisp')]"/>              
        </xsl:when>
            <xsl:when test="$fieldtype='User' or $fieldtype='UserMulti'">
          <xsl:value-of select="@*[name()=concat($fieldtitle, '.span')]" disable-output-escaping="yes"/>
        </xsl:when> 
            <xsl:otherwise>
          <xsl:apply-templates mode="PrintField" select="$group">
            <xsl:with-param name="thisNode" select="."/>
          </xsl:apply-templates>
        </xsl:otherwise>
        </xsl:choose>
      <span style="font-weight: lighter;display: inline-block;">
        <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
        <xsl:choose>
            <xsl:when test="$XmlDefinition/List/@Direction='rtl' or $LCID='1037'">
                <xsl:text disable-output-escaping="yes">&amp;#8207;</xsl:text>
          </xsl:when>
            <xsl:otherwise>
                <xsl:text disable-output-escaping="yes">&amp;#8206;</xsl:text>
          </xsl:otherwise>
        </xsl:choose>(<xsl:value-of select="$RowCount"/>)
      </span>
    </td>
    </xsl:if>
  </tr>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.