Tell me how to set the default display of an element? Didn't find any good example anywhere on how to return the style and value of a list item to its default?

(function () { 
    var linkFilenameFiledContext = {}; 
    linkFilenameFiledContext.Templates = {}; 
    linkFilenameFiledContext.Templates.Fields = { 
        "LinkFilename": { "View": linkFilenameFiledTemplate } 

function linkFilenameFiledTemplate(ctx) {
    var fileRef = ctx.CurrentItem.FileRef;
    var encoded = encodeURIComponent(fileRef);
    var url = "http://sp-test/sites/test";
    var FileLeafRef = ctx.CurrentItem.FileLeafRef;
    var type = ctx.CurrentItem.File_x0020_Type;
    var LinkFilename = ctx.LinkFilename;
    var Project = ctx.CurrentItem.Project;
    if(Project == "Active" && ctx.CurrentItem.File_x0020_Type == ""){
      return "<b><span><a href=" + url + encoded + ">" + FileLeafRef + "</a></span></b>";
    } else {
      return //value and item style default?????

1 Answer 1


You could add value and style directly like,just like writing html:

<b><span style='add css you want'><a href=" + url + encoded + ">" + FileLeafRef + "</a></span></b>

List View CSR introduction: Client Side Rendering: List Views

You could try to get it in ctx.ListData.Row.

  • This is not the default rendering :-( the whole grouping of elements and their sequence gets confused. Nov 27, 2020 at 9:29
  • If you use CSR to change the style, it will not be the default render. You can use the CSS selector to select the specified element and change the style.
    – Amos
    Nov 27, 2020 at 9:41
  • Unfortunately, CSR is not a flexible solution that does not allow you to return to the default rendering of an element, therefore I consider it relevant only for list items, it is absolutely not suitable for working with folders and documents, it knocks down filters and grouping of documents, this is its very huge disadvantage ... Nov 27, 2020 at 9:42
  • Try to find the default elements in ctx.ListData.Row.
    – Amos
    Nov 27, 2020 at 9:46
  • Thank you, a solution with ctx.ListData.Row more or less optimal :) Change your answer. Nov 27, 2020 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.