【问题标题】:Sharepoint 2013 JSLink (CSR) Not WorkingSharepoint 2013 JSLink (CSR) 不工作
【发布时间】:2014-12-17 20:33:42
【问题描述】:

我正在尝试按照本教程将我们的列表视图作为手风琴:

https://code.msdn.microsoft.com/office/Client-side-rendering-code-ccdb2a0e

-

我按照教程进行操作:

创建一个自定义列表,在列表中添加一个新列:

名称:描述

类型:多行文本

编辑默认的新表单

转到列表视图 Web 部件属性并将 JSLink 文件 (~sitecollection/Style Library/JSLink-Samples/Accordion.js) 添加到其他选项卡下的 JS 链接属性。点击应用。

-

什么都没有改变,所以我在那个页面中添加了一个脚本编辑器并粘贴了 js 代码。然后它有点工作。

我做错了什么吗?谢谢!

【问题讨论】:

    标签: sharepoint rendering client-side jslink


    【解决方案1】:

    不幸的是,当Description 字段是指定示例中的Plain text 类型时,列表视图会正确呈现。

    要在Description 字段为Rich textEnhanced 类型时正确呈现它,请将accordionTemplate 函数替换为该函数:

    function accordionTemplate(ctx) { 
        var title = ctx.CurrentItem["Title"]; 
        var description = ctx.CurrentItem["Description"]; 
    
        // construct List Item  
        return "<h2>" + title + "</h2><p>" + $(description).html() + "</p><br/>"; 
    } 
    

    结果


    我建议您尝试另一种方法将列表视图呈现为手风琴,如Customize the rendering of a List View in Sharepoint 2013: Displaying List Items in Accordion 文章中所示。

    要点:

    • jQuery IU Accordion 用于将列表项呈现为可折叠 内容面板
    • 演示如何加载多个 JavaScript 库(例如 jQuery) 使用JSLink 属性

    结果

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 1970-01-01
      • 2019-07-20
      • 1970-01-01
      • 2015-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      相关资源
      最近更新 更多