locked
XSLT code for Selecting a most recent date from stack of dates RRS feed

  • Question

  • Hey all,

    I am working on XSLT code, ran into small problem, i.e i wan to show a date field in a report which should be recent of all dates reported. In detail if a person submitted a request form with one date and later comes up and edit the request form with other date, then he should able to see only most recent date in the report. I making changes to the code, but all dates are showing up in the report. I only need most recent date there.

    Could someone provide logic for that, the below is the code i am working on.

    <xsl:variable name="dvt_11_automode">0</xsl:variable>
     <xsl:template name="dvt_11">
     <xsl:variable name="dvt_StyleName">Table</xsl:variable>
     <xsl:variable name="dvt_ParentRow" select="current()" />
    <xsl:variable name="Rows" select="../../../Project_Milestone/Rows/Row[(@Project_x0020_Name=$dvt_ParentRow/@Project_x0020_Name0) and (@LBE_x0020_date_x0020_for_x0020_P = '1')]" />
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
    <tr valign="top">
    <xsl:if test="$dvt_11_automode = '1'" ddwrt:cf_ignore="1">
    <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
    </tr>
    <xsl:call-template name="dvt_11.body">
    <xsl:with-param name="Rows" select="$Rows" />
    <xsl:with-param name="dvt_ParentRow" select="$dvt_ParentRow" />
    </xsl:call-template>
    </table>
    </xsl:template>
    <xsl:template name="dvt_11.body">
    <xsl:param name="Rows" />
    <xsl:param name="dvt_ParentRow" />
    <xsl:for-each select="$Rows">
    <xsl:call-template name="dvt_11.rowview" />
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="dvt_11.rowview">
    <tr>
    <xsl:if test="position() mod 2 = 1">
    <!--<xsl:attribute name="class">ms-alternating</xsl:attribute>-->
    </xsl:if>
    <xsl:if test="$dvt_11_automode = '1'" ddwrt:cf_ignore="1">
    <td class="ms-vb" width="1%" nowrap="nowrap">
    <span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
    </td>
    </xsl:if>
    <td class="style9">
    <xsl:value-of select="ddwrt:FormatDate(string(@Latest_x0020_Best_x0020_Estimate), 1033, 1)" />
    </td>
    </tr></xsl:template>
    • Moved by Mike Walsh FIN Wednesday, March 23, 2011 5:57 PM XSLT = SPD = Customization (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    Wednesday, March 23, 2011 4:03 PM

Answers

  • Hi SP,

    Not quite sure what is actually the problem...not quite syncing into what is happening.

    Two possibilities tho.  Either don't grab the data, or if you do just show the one(s) you want.

    You select the data here:

    <xsl:variable name="Rows" select="../../../Project_Milestone/Rows/Row[(@Project_x0020_Name=$dvt_ParentRow/@Project_x0020_Name0) and (@LBE_x0020_date_x0020_for_x0020_P = '1')]" />
    And you display it here:
    <xsl:value-of select="ddwrt:FormatDate(string(@Latest_x0020_Best_x0020_Estimate), 1033, 1)" />
     
    If you can't get the select to bring in the correct data, then in the dvt_11.rowview template put an xsl:if in to not paint it.  You already have one example that highlights every-other row.  Just tell it not to put the data out.
     
    Don't know if you've read marc anderson's blogs or his unlocking the mysteries of the data view web part book...found them very helpful.
     
    Best,
     
    S'
    • Marked as answer by David HM Thursday, March 31, 2011 10:17 AM
    • Unmarked as answer by SP.Developer Thursday, April 7, 2011 7:44 PM
    • Marked as answer by SP.Developer Thursday, April 7, 2011 7:44 PM
    Wednesday, March 30, 2011 2:42 AM