简体   繁体   English

具有Jquery和Ratings字段的SharePoint 2010自定义XSL视图呈现

[英]SharePoint 2010 Custom XSL View Rendering with Jquery and Ratings Field

I'm developing a SharePoint 2010 Internet facing web site with FAQ capabilities. 我正在开发具有FAQ功能的面向SharePoint 2010 Internet的网站。

I've got a Custom list containing ID, Title (rennamed to "Question"), Answer and Fileds for Rating. 我有一个自定义列表,其中包含ID,标题(更名为“问题”),答案和评定等级。

I would like writing a XSL Stylesheet in order to customize the list view rendering in the following way: 我想编写一个XSL样式表,以便通过以下方式自定义列表视图呈现:

  • FAQ Items should be displayed as an accordion, with JQuery FAQ项目应显示为带有JQuery的手风琴
  • Each FAQ could be rated by any users. 每个常见问题都可以由任何用户进行评分。

So, I wrote this XSL : 所以,我写了这个XSL:

<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 js" 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:js="urn:custom-javascript" >

<xsl:import href="/_layouts/xsl/main.xsl"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">

<script type="text/javascript" language="javascript" >
        $(document).ready(function () {

            $('#faqAnswerAccordion').accordion({
                autoHeight: false,
                collapsible: true
            });

        });

    </script>   

    <a id="top"></a>
    <div id="faqAnswerAccordion">
        <xsl:apply-templates select="//Row" mode="Item" />
    </div>
</xsl:template>

<xsl:template mode="Item" match="Row[../../@TemplateType='100']">
    <xsl:param name="Fields" select="."/>
    <xsl:param name="Collapse" select="."/>
    <xsl:param name="Position" select="1"/>
    <xsl:param name="Last" select="1"/>
    <xsl:variable name="thisNode" select="."/>

    <h3 id="header_{@ID}">
        <a id="{@ID}" href="#" ><xsl:value-of select="@Title" disable-output-escaping="yes"/></a>
    </h3>
    <div>
        <p>
            <xsl:value-of select="@Answer" disable-output-escaping="yes"/>
        </p>
        <p>
            Please rate this FAQ: 
            <xsl:apply-templates select="$Fields[@Name='AverageRating']" mode="PrintField">
                <xsl:with-param name="thisNode" select="."/>
                <xsl:with-param name="Position" select="$Position"/>
            </xsl:apply-templates>
        </p>
    </div>
</xsl:template>

With that stylesheet, the Jquery Accordion is not generated, but rating star are present. 使用该样式表,不会生成“ jQuery手风琴”,但是会出现星级评定。

If I replace the following template definition 如果我替换以下模板定义

<xsl:template match="/">

By 通过

<xsl:template match="View">

So, Jquery Accordion work fine, but the Rating Stars are not. 因此,“ jQuery手风琴”可以正常工作,但“评级之星”却不能。

Any Ideas ? 有任何想法吗 ?

Thank a lot. 非常感谢。

尝试将mode更改为numberbody

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM