30.6.10

XSL per dashboard collegate a dataview in sharepoint designer ? Voilà

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:WebControls="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:output method="html" indent="no"/>
    <xsl:param name="dvt_apos">&apos;</xsl:param>
    <xsl:variable name="dvt_1_automode">0</xsl:variable>
    <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:WebControls="Microsoft.SharePoint.WebControls">
        <xsl:call-template name="dvt_1"/>
    </xsl:template>
    <xsl:template name="dvt_1">
        <xsl:param name="ParentPath"/>
        <xsl:variable name="dvt_StyleName">Table</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
        <xsl:variable name="dvt_RowCount" select="count($Rows)" />
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:call-template name="dvt_1.footer">
            <xsl:with-param name="Rows" select="$Rows" />
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="percentformat">
        <xsl:param name="percent"/>
        <xsl:choose>
            <xsl:when test="format-number($percent, '#,##0%;-#,##0%')= 'NaN'">0%</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="format-number($percent, '#,##0%;-#,##0%')" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="ChartRow">
        <xsl:param name="RowName"></xsl:param>
        <xsl:param name="Value"></xsl:param>
        <xsl:param name="PercentValue"></xsl:param>
        <tr>
            <td class="ms-formbody" width="125px" style="vertical-align:middle">
                <xsl:value-of select="$RowName"/>: <xsl:value-of select="$Value" />
                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;
            </xsl:text>(<xsl:call-template name="percentformat">
                    <xsl:with-param name="percent" select="$PercentValue"/>
                </xsl:call-template>)
            </td>
            <td>
                <table width="100%" >
                    <tr>
                        <td width="{round($PercentValue*100)+1}%" height="15px" class="ms-selected">
                            <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                        </td>
                        <td width="100%" >
                            <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </xsl:template>
    <xsl:template name="dvt_1.footer">
        <xsl:param name="ParentPath" />
        <xsl:param name="Rows" />
        <xsl:variable name="NotStarted" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Priority) = '(1) Alta'])" />
        <xsl:variable name="InProgress" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Priority) = '(2) Normale'])" />
        <xsl:variable name="Completed" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Priority) = '(3) Bassa'])" />
        <xsl:variable name="AllTasks" select="count(/dsQueryResponse/Rows/Row)" />
        <xsl:variable name="percentNotStarted" select="$NotStarted div $AllTasks" />
        <xsl:variable name="percentInProgress" select="$InProgress div $AllTasks" />
        <xsl:variable name="percentCompleted" select="$Completed div $AllTasks" />
        <table width="100%" cellspacing="0" cellpadding="2" style="border-right: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0; border-left-style: solid; border-left-width: 1; border-top-style: solid; border-top-width: 1;">
            <xsl:call-template name="ChartRow">
                <xsl:with-param name="RowName">Alta</xsl:with-param>
                <xsl:with-param name="Value">
                    <xsl:value-of select="$NotStarted"/>
                </xsl:with-param>
                <xsl:with-param name="PercentValue">
                    <xsl:value-of select="$percentNotStarted"/>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="ChartRow">
                <xsl:with-param name="RowName">Normale</xsl:with-param>
                <xsl:with-param name="Value">
                    <xsl:value-of select="$InProgress"/>
                </xsl:with-param>
                <xsl:with-param name="PercentValue">
                    <xsl:value-of select="$percentInProgress"/>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="ChartRow">
                <xsl:with-param name="RowName">Bassa</xsl:with-param>
                <xsl:with-param name="Value">
                    <xsl:value-of select="$Completed"/>
                </xsl:with-param>
                <xsl:with-param name="PercentValue">
                    <xsl:value-of select="$percentCompleted"/>
                </xsl:with-param>
            </xsl:call-template>
        </table>
    </xsl:template>
</xsl:stylesheet>

No comments:

Post a Comment