如何在 SharePoint Designer 2007 中的联接数据源上创建筛选的数据视图

发布于 2024-11-19 03:15:28 字数 3915 浏览 1 评论 0原文

我正在尝试使用 SharePoint Designer 2007 创建 MOSS 2007 的筛选 DataView。以下简化示例演示了我想要完成的任务。

假设我有两个列表:颜色和人物。人员列表有一个名为“最喜欢的颜色”的查找列,允许用户从颜色列表中进行选择。

我想创建一个 DataView,它只显示没有人选择作为他们最喜欢的颜色的颜色。

我通过插入以下 XSL 代码成功创建了一个 DataView,它显示每种颜色以及选择该颜色的人数

<xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />

我尝试将相同的逻辑应用于 DataView 查询,如下所示,但是这仍然返回所有行:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title]) = 0]"/>

我认为上面的问题是在查询发生时, current() 函数不起作用,因为没有当前行。因此,我还尝试使用完整的参考,这产生了相同的结果:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>

Is it possible to do the type of query I Want using XSL?如果是这样,我哪里出了问题?完整的XSL如下:

<XSL><xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" 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:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
    <xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
    <xsl:variable name="dvt_StyleName">Table</xsl:variable>
    <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
    <tr valign="top">
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
        <th class="ms-vh" nowrap="nowrap">Color</th>
        <th class="ms-vh" nowrap="nowrap">Number of People</th>
    </tr>
    <xsl:call-template name="dvt_1.body">
        <xsl:with-param name="Rows" select="$Rows"/>
    </xsl:call-template>
    </table>
</xsl:template>
<xsl:template name="dvt_1.body">
    <xsl:param name="Rows"/>
    <xsl:for-each select="$Rows">
        <xsl:call-template name="dvt_1.rowview"/>
    </xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
    <tr>
        <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="class">ms-alternating</xsl:attribute>
        </xsl:if>
        <xsl:if test="$dvt_1_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="ms-vb">
            <xsl:value-of select="@Title"/>
        </td>
        <td class="ms-vb">
            <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />
        </td>
    </tr>
</xsl:template>

I am trying to create a filtered DataView for MOSS 2007 using SharePoint Designer 2007. The following simplified example demonstrates what I am trying to accomplish.

Suppose I have two lists: Colors and People. The list of people has a lookup column called Favorite Color that allows the user to select from the list of colors.

I want to create a DataView that will only display the colors that nobody has selected as their favorite color.

I have successfully created a DataView that shows each color and the number of people who have chosen that color by inserting the following XSL code:

<xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />

I tried to apply to same logic to the DataView query as shown below, but this still returned all the rows:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title]) = 0]"/>

I think the problem with the above is that at the time the query takes place, the current() function doesn't work because there isn't a current row. So I also tried using a complete reference, which yielded the same results:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>

Is it possible to do the type of query I want using XSL? If so, where have I gone wrong? The complete XSL is given below:

<XSL><xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" 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:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
    <xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
    <xsl:variable name="dvt_StyleName">Table</xsl:variable>
    <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
    <tr valign="top">
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
        <th class="ms-vh" nowrap="nowrap">Color</th>
        <th class="ms-vh" nowrap="nowrap">Number of People</th>
    </tr>
    <xsl:call-template name="dvt_1.body">
        <xsl:with-param name="Rows" select="$Rows"/>
    </xsl:call-template>
    </table>
</xsl:template>
<xsl:template name="dvt_1.body">
    <xsl:param name="Rows"/>
    <xsl:for-each select="$Rows">
        <xsl:call-template name="dvt_1.rowview"/>
    </xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
    <tr>
        <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="class">ms-alternating</xsl:attribute>
        </xsl:if>
        <xsl:if test="$dvt_1_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="ms-vb">
            <xsl:value-of select="@Title"/>
        </td>
        <td class="ms-vb">
            <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />
        </td>
    </tr>
</xsl:template>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白馒头 2024-11-26 03:15:28

我实际上还没有尝试过这个,但是如果你基本上按照安德鲁的建议去做,首先循环浏览颜色列表,会怎么样。如果不满足条件,则不显示该行。

   <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row"/>

进而

<xsl:template name="dvt_1.rowview">
<xsl:variable name="title" select="@Title" />
<xsl:if test="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title]) > 0">
<tr>
    <xsl:if test="position() mod 2 = 1">
        <xsl:attribute name="class">ms-alternating</xsl:attribute>
    </xsl:if>
    <xsl:if test="$dvt_1_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="ms-vb">
        <xsl:value-of select="@Title"/>
    </td>
    <td class="ms-vb">
        <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title])" />
    </td>
</tr>
</xsl:if>
</xsl:template>

I haven't actually tried this but what if you do basically what Andrew suggests, looping through the Colors list first. Just don't display the row if the criteria isn't met.

   <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row"/>

and then

<xsl:template name="dvt_1.rowview">
<xsl:variable name="title" select="@Title" />
<xsl:if test="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title]) > 0">
<tr>
    <xsl:if test="position() mod 2 = 1">
        <xsl:attribute name="class">ms-alternating</xsl:attribute>
    </xsl:if>
    <xsl:if test="$dvt_1_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="ms-vb">
        <xsl:value-of select="@Title"/>
    </td>
    <td class="ms-vb">
        <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title])" />
    </td>
</tr>
</xsl:if>
</xsl:template>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文