0

我正在尝试计算列表中的角色数量。有3个阶段,打开,提供和填充。有2个部门;基础设施和业务。所以我想显示一个带有以下标题的表格;部门 | 打开 | 报价 | 填充。我将列出每个部门,然后列出列表中每个值的总数。以下是列表示例。

Department     | Status
_________________________
Infrastructure | open
Infrastructure | open
Infrastructure | offer
Infrastructure | filled
Business       | filled
Business       | offer
Business       | open

我想按打开、提供和填充对部门进行分组,并计算每个部门的数量,然后在表格中显示该值。下面的代码显示了我如何从列表中提取基础设施数据。

<xsl:template name="dvt_1">
    <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.body">
       <xsl:with-param name="Rows" select="$Rows"/>
    </xsl:call-template>                                                                                                
</xsl:template>

<xsl:template name="dvt_1.body">
    <xsl:param name="Rows" />

    <xsl:variable name="InfraOpen" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='OPEN')])"/>

    <xsl:variable name="InfraOffer" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='OFFER')])"/>

    <xsl:variable name="InfraFilled" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='FILLED')])"/>

   <table width="100%" cellspacing="0" cellpadding="2" 
                       style="border-right: 1 solid #008ce6; 
                       border-bottom: 1 solid #008ce6; 
                       border-left:  1 solid #008ce6; 
                       border-top:  1 solid #008ce6;">
<tr style="font-family: Arial, Helvetica, sans-serif; font-size: small"> 
<th>ORGANISATION</th><th>OPEN</th><th>OFFER</th><th>FILLED</th></tr>

<xsl:call-template name="ChartRow">      
      <xsl:with-param name="RowName">
        Infrastructure
      </xsl:with-param>      
      <xsl:with-param name="ValueOpen">
        <xsl:value-of select="$CISopen"/>
      </xsl:with-param>
      <xsl:with-param name="ValueOffer">
        <xsl:value-of select="$CISoffer"/>
      </xsl:with-param>
      <xsl:with-param name="ValueFilled">
        <xsl:value-of select="$CISfilled"/>
      </xsl:with-param>
</xsl:call-template>
</table>
</xsl:template>

<xsl:template name="ChartRow">
  <xsl:param name="RowName"></xsl:param>
  <xsl:param name="ValueOpen"></xsl:param>
  <xsl:param name="ValueOffer"></xsl:param>
  <xsl:param name="ValueFilled"></xsl:param>

  <tr style="font-family: Arial, Helvetica, sans-serif; font-size: small">
  <td class="ms-formbody" style="vertical-align:middle">
  <xsl:value-of select="$RowName"/>
  </td>
  <td>
    <xsl:value-of select="$ValueOpen"/> 
  </td>
  <td>
    <xsl:value-of select="$ValueOffer"/> 
  </td>
  <td>
    <xsl:value-of select="$ValueFilled"/> 
  </td>
 </tr>
</xsl:template>                 

以下是所需的输出

Department     | Open| Offer| Filled
____________________________________
Infrastructure | 2   |  1   |  1
Business       | 1   |  1   |  1

此代码在 SP Designer 中有效,但无法在网页中加载 web 部件。我已经阅读了这个并认为我需要使用 MUENCHIAN 分组,有谁知道我将如何处理这个?

4

0 回答 0