Totals in the DataView when the View is Filtered
Hello again,
We are chugging along with the next version of Office and are super busy around here trying to get the right features into the next version of the Data View and SharePoint customization story. That said, I was looking through some older posts and saw this one:
https://blogs.msdn.com/frontpoint/archive/2004/04/30/123982.aspx
from Rob. This is a really cool feature for showing the count of items in your view. However, this count is not accurate once you start using Ad Hoc filtering. This post is about extending the above example by making a minor edit to the XSLT in code view.
So....
- Create a Data View of some data source (I'll just assume you know how if you're still reading this post)
- Click on Data then Style
- Enable the default toolbar and the Show View Footer checkboxes on the Options tab and click OK
- Drag some data value into the View Footer and use the OOUI to change this to a COUNT (this is how far the above article gets you, this next step is the Money step)
- Switch to code view (this next part is a little complicated - you are going to modify the View Footer XSLT and then move the code that says where to display the View Footer*)
- Click Edit and then Find
- find the following: dvt_1.footer
- the code should look like this:
- <xsl:call-template name="dvt_1.footer">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
- select this code and CUT
- Click Edit and then Find
- find the following: groupend
- the code should look like this:
- <xsl:variable name="groupend"><xsl:value-of select="ddwrt:NameChanged('', -1)"/></xsl:variable>
</xsl:if>
</xsl:foreach>
</xsl:template>
- paste in the code from step 2 immediately after the </xsl:foreach> so it looks like this:
- <xsl:variable name="groupend"><xsl:value-of select="ddwrt:NameChanged('', -1)"/></xsl:variable>
</xsl:if>
</xsl:for-each>
<xsl:call-template name="dvt_1.footer">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</xsl:template>
- <xsl:variable name="groupend"><xsl:value-of select="ddwrt:NameChanged('', -1)"/></xsl:variable>
- click Edit and then Find
- Find the following (again): dvt_1.footer
- The code should look like this:
- <xsl:template name="dvt_1.footer">
<xsl:param name="Rows"/>
<table cellSpacing="0" cellPadding="4" border="0" width="100%">
<tr>
<td class="ms-vb"><xsl:value-of select="count(/dataroot/Categories/CategoryID)"/></td>
</tr>
</table>
</xsl:template>
- Remove the <table> code so it looks like this
- <xsl:template name="dvt_1.footer">
<xsl:param name="Rows"/>
<tr>
<td class="ms-vb"><xsl:value-of select="count(/dataroot/Categories/CategoryID)"/></td>
</tr>
</xsl:template>
- <xsl:template name="dvt_1.footer">
- Change the Count code so it references a variable rather than a literal path
- <xsl:template name="dvt_1.footer">
<xsl:param name="Rows"/>
<tr>
<td class="ms-vb"><xsl:value-of select="count($Rows)"/></td>
</tr>
</xsl:template>
- <xsl:template name="dvt_1.footer">
- Save the page and preview in the browser
- Change the Filter and you should see the count change
I am hoping this will be much easier in the next release.
-John
*technical details: our design is to put the view footer outside the body template that displays your data. Because of this, the scope of the $Rows parameter is outside the current Repeating Data Region. What we have to do is move the scope inside the current RDR. In doing so, we need to delete the <table> code so it will be valid HTML.
Comments
Anonymous
November 26, 2007
PingBack from http://feeds.maxblog.eu/item_676889.htmlAnonymous
January 21, 2009
PingBack from http://www.keyongtech.com/2019290-remove-the-words-count-and