0

I am working on a sharepoint list with items view like below

name    | code  | total   |  date
build1    x1      10        apl-2013
build2    x50     60        may-2013
build3    x90     450       jul-2013

For each new items there will be new column depending on date field, and it's workinkg fine with that except sorting ascending or descending. I have reached on transposing the date field, but I stuck on showing the total field, like shown on the table below,

     name    |  code   | apl-2013 |  may-2013 |  jul-2013
    build1     x1           10          60         450
    build2     x50          10          60         450
    build3     x90          10          60         450

But I want to get the html out put like this:-

name    |  code   | apl-2013 |  may-2013 |  jul-2013
build1     x1        10             0           0
build2     x50        0            60           0
build3     x90        0             0         450

Here is the xml for the list

<rs:data>
<z:row name='build1' ows_code='x1' ows_total='10' ows_date='string;#apl-2013' />
<z:row name='build2' ows_code='x50' ows_total='60' ows_date='string;#may-2013' />
<z:row name='build3' ows_code='x90' ows_total='450' ows_date='string;#jul-2013' />
</rs:data>

I need your help, thanks!

0

I figured out and got the solution. The dataview sorts, groups(muenchian grouping) and adds columns for date values, when new item is added.

I add on the top xsl:template before ---<--xsl:template match="/".........)

<xsl:key name="Months" match="@ows_date" use="."/>

Then at table headers

<!----to transpose the date field on table headers-----><xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(@ows_date) = generate-id(key('Months', @ows_date)[1])]">
 <xsl:sort select="ddwrt:FormatDate(string(@ows_date), 1038, 5)" /> 
<th style="text-align: left">
 <xsl:value-of select="@ows_date"/>
 </th>
 </xsl:for-each>

on the rowview template

<xsl:variable name="currentMonth" select="@ows_date"/>
 <xsl:variable name="currenttotal" select="@ows_total"/>

Finally on transposed rows

<xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(@ows_date) = generate-id(key('Months', @ows_date)[1])]">
 <xsl:sort select="ddwrt:FormatDate(string(@ows_date), 1038, 5)" />
 <td>
    <xsl:choose>
      <xsl:when test="$currentMonth = @ows_date">
      <xsl:value-of select="$currenttotal"/>
     </xsl:when>
     <xsl:otherwise>0%</xsl:otherwise>
    </xsl:choose>
   </td>
  </xsl:for-each>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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