Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListRunning total on xsl fieldRunning total on xsl field
Previous
 
Next
New Post
12/10/2007 12:50 PM
 

I have created a UDT that has two different fields. An activity name field and a completed date field. I have also created an xsl sheet that takes the activity name field and if it is one thing, then the Points column is X. If the activity name is another thing then the points column is XX. What I need to do now is create a forth column called Total and have that be a running total column. I'm assuming that I need to do this via a variable of some sort but I'm new to xsl and I'm unsure of how to accomplish this. Can it be done? Is there a better way to get the "sum" of my points column? I simply want  the total or sum of all points that a person has accumulated by their entered activities. Thanks in advance.

Activity Completed Date Points Total
Gym 2/1/2007 5  
HealthyU 2/5/2007 15  
Gym 3/5/2007 5  

Here is my xls file.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:udt="DotNetNuke/UserDefinedTable">
  <xsl:output method="xml" version="1.0"  indent="yes" omit-xml-declaration="yes"/>
  <xsl:template match="/udt:UserDefinedTable">
   <xsl:variable name ="NameOfCurrentUser"        select ="udt:Context/udt:UserName"/>
   <xsl:variable name ="IsAdministrator"          select ="udt:Context/udt:IsAdministratorRole='true'"/>
   <xsl:variable name ="NameOfCreatedByColumn"><xsl:value-of select="udt:Fields[udt:FieldType='CreatedBy']/udt:ValueColumn"

/>_UDT_Original</xsl:variable>

    <!-- Sorting Support-->
    <xsl:variable name="OrderBy" select="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:SortColumn"/>
    <xsl:variable name="OrderDirection" select="//udt:Context/udt:OrderDirection"/>
    <xsl:variable name="OrderType">
      <xsl:variable name ="DataType" select ="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:FieldType"/>
      <xsl:choose>
        <xsl:when test="$DataType='Int32' or $DataType='Decimal' or $DataType='Currency'">number</xsl:when>
        <xsl:otherwise>text</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>


    <table cellspacing="0" cellpadding="4"  border="0"  style="border-width:0px;border-collapse:collapse;">

  <tr class="NormalBold UDT_Table_Head">
   <th></th>
   <xsl:for-each select="udt:Fields">
    <xsl:if test="udt:Visible='true' or udt:Visible='True'">
     <th>
      <xsl:value-of select="udt:FieldTitle" />
     </th>
    </xsl:if>
   </xsl:for-each>
   <th>Points</th>
   <th>Total</th>
  </tr>

  <xsl:for-each select="udt:Data[*[name()=$NameOfCreatedByColumn]=$NameOfCurrentUser or $IsAdministrator]">
  <xsl:variable name="id" select="udt:UserDefinedRowId" />
  <tr>
   <xsl:variable name="PointsTotal">5</xsl:variable>
   <xsl:attribute name="class">
    <xsl:choose>
     <xsl:when test="position() mod 2 = 1">Normal UDT_Table_AlternateItem</xsl:when>
     <xsl:otherwise>Normal UDT_Table_Item</xsl:otherwise>
    </xsl:choose>
   </xsl:attribute>
   <td>
    <xsl:if test="udt:EditLink">
     <a>
     <xsl:attribute name="href">
      <xsl:value-of select="udt:EditLink" />
     </xsl:attribute>
     <img border="0" alt="edit">
     <xsl:attribute name="src">
      <xsl:value-of select="//udt:Context/udt:ApplicationPath" />/images/edit.gif
     </xsl:attribute>
     </img>
     </a>
    </xsl:if>
   </td>

   <td>
    <xsl:value-of select="udt:Activity" />
   </td>

   <td>
    <xsl:value-of select="udt:CompletedDate_UDT_Value" />
   </td>
   
   <xsl:if test="udt:Activity='Gym'">
    <td>
     <xsl:value-of select="5" />
    </td>
   </xsl:if>

   <xsl:if test="udt:Activity='Lunch n Learn'">
    <td>
     <xsl:value-of select="10" />
    </td>
   </xsl:if>
 
   <xsl:if test="udt:Activity='Healthyu'">
    <td>
     <xsl:value-of select="25" />
    </td>
   </xsl:if>
  </tr>
  </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>

 
New Post
12/10/2007 3:25 PM
 
 
New Post
12/10/2007 3:47 PM
 

Thanks Stefan,

Your blog was how I got as far as I did. Great job and I really appreciate the detail. My difference comes when I created a "fake" column called points. It really isn't a column  in the UDT so when I tried to use your sum formula it gave me a bunch of errors. Something about it needing to be a node set. I can make the sum function work on an actual column in the UDT but is it possible from a column built only thru the xsl?

Thanks again,

Matthew

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListRunning total on xsl fieldRunning total on xsl field


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out