Second Life of a Hungarian SharePoint Geek

August 31, 2011

Moving totals to the bottom of the view

Filed under: SP 2010, Totals, Views — Tags: , , — Peter Holpar @ 22:43

In my last post I showed you how to add totals to your views programmatically.

Having the totals created, I’ve added a few items to my list that looks like this now:

image

As you can see, totals are displayed at the top of the view. That is really not the same the users got used to in Excel (or in the case of paper based tables), where aggregations usually displayed at the bottom of the sheet. So it is not a surprise that customers often request us to move the totals to the bottom of the view.

I wish all requirement would be so easy to implement!

In a former post I showed you how to create customized versions of the main.xsl and vwstyles.xsl files to alter view rendering. If you are ready with cloning that files and set the view in SharePoint Designer to use the new the main.xsl as described in that post, open the copy of the vwstyles.xsl and look for the comment:

<!– total first –>

The first occurrence you find is within a template:

<xsl:template match="View[ViewStyle/@ID=’14’]" mode="RenderView">

Find the second one that is in this template:

<xsl:template match="View" mode="RenderView">

Cut the following block:

  1. <!– total first –>
  2. <xsl:if test="Aggregations[not(@Value='Off')]/FieldRef">
  3.   <tr>
  4.     <xsl:if test="$HasExtraColumn">
  5.       <td/>
  6.     </xsl:if>
  7.     <xsl:if test="$InlineEdit">
  8.       <td width="1%"/>
  9.     </xsl:if >
  10.     <xsl:apply-templates mode="aggregate" select="ViewFields/FieldRef[not(@Explicit='TRUE')]">
  11.       <xsl:with-param name="Rows" select="$AllRows"/>
  12.       <xsl:with-param name="GroupLevel" select="0"/>
  13.     </xsl:apply-templates>
  14.   </tr>
  15. </xsl:if>

and paste it to the end of the template block. I suggest to replace the word first to last in the text of the comment.

Save the file and run IISRESET if the customized vwstyles.xsl was already loaded by SharePoint.

The following screenshot shows the result:

image

Advertisements

6 Comments »

  1. Hi Peter,
    Thanks for this great post, I spent a lot of time trying to obtain this.
    I also have another problem – how to rename “Sum=” with “Total:”?
    After some research I’ve found that the text “Sum” comes from wss.resx. Renaming the word “Sum” with “Total:” does not remove the “=” sign, so I have something like that: “Total:=”

    Thank you,
    Roman

    Comment by Roman — September 8, 2011 @ 12:03

    • Hi Roman,

      Thanks for the feedback! I don’t suggest altering wss.resx, instead you can alter the XSL used to format the given list. That does not affect other lists on the site and is a supported solution. I plan to write a post about how to conditionally format totals, that I hope will answer your question as well.

      Peter

      Comment by Peter Holpar — September 8, 2011 @ 15:43

  2. Hi Peter,

    Thanks a lot for your advice! Unfortunately, XSL is my big headache, I’m trying to avoid it as much as possible.
    I’ll stay with my finger on F5 key, refreshing your blog and waiting for the post with conditionally formating 🙂

    Roman

    Comment by Roman — September 14, 2011 @ 12:02

    • Hi Roman,

      You can stop pressing F5. Instead, check the post here. I hope you find the answer for your question.

      Peter

      Comment by Peter Holpar — September 14, 2011 @ 23:39

  3. Hello Peter,

    One more question – is it possible to have 2 rows of totals, depending on a status field?

    Thank you,
    Roman

    Comment by Roman — October 3, 2011 @ 13:48

  4. Hi,
    If I group items together the totals for the groups still appear at the top. How can I move those totals to the bottom as well?

    Thank you,
    Mahen

    Comment by Mahen — November 1, 2012 @ 09:22


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: