在 SharePoint 列表中添加 disable-output-escaping 的位置在哪里?

5

是的,我知道这是一个重复的问题,但其他答案现在已经过时了。我正在使用SharePoint Designer 2013和SharePoint在线。

我想为SharePoint列表视图设置disable-output-escaping=yes。

这是我尝试过的:

  • 我将字段类型设置为数字。这适用于早期版本的SharePoint,但不再适用于SharePoint在线。
  • 我尝试在SharePoint Designer中打开设计视图,但在SharePoint Designer 2013中不存在该功能。
  • 我尝试设置自定义XSL,但会导致错误。我应该在哪里添加XSL才能使其正常工作?它本身引用了main.xsl。如果我知道那个文件在哪里,我可以将其复制为创建自己的XSL的起点,但我无法在站点中找到它。

这是我的视图aspx的相关部分:

<FieldRef Name="After_x0020_Mitigation"/></ViewFields>
<RowLimit Paged="TRUE">100</RowLimit><Aggregations Value="Off"/
<JSLink>clienttemplates.js</JSLink><XslLink default="TRUE">Main.xsl</XslLink>
1个回答

0

我不知道要把'disable-output-escaping=yes'放在哪里,也找不到相关信息。

但是,你可以使用字段模板来实现这个结果。类似这样的:

(function () {  
    // Create an object that have the context information about the fields that we want to change the rendering of.   
    var nameFiledContext = {};  
    nameFiledContext.Templates = {};  
    nameFiledContext.Templates.Fields = {  
        // Apply the new hyperlink HTML Rendering to the field in your view.  Swap out "<Your Field Name>" for your field name 
        "<Your Field Name>": { "View": nameFiledTemplate }  
    };  
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(nameFiledContext);  
})();  
  
// This function applies the rendering logic 
function nameFiledTemplate(ctx) {  
    var name = ctx.CurrentItem.ID;  //Swap out name variable for whatever field contains your hyperlink name
            
    return "<a target='_blank' href='<Your Hyperlink Here>'>"   
        + name + "</a>";      //Put the url for your hyperlink in the href above
}  


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接