1

I am looking for CSR Documentation. If I Google something from the Server-Side API, I get the documentation right away.

For example, Googling SPWeb, the first result is the documentation: https://msdn.microsoft.com/library/Microsoft.SharePoint.SPWeb.
However, when I try the same thing with CSR functions, I get examples but no documentation.

A couple of things that I hope documentation will clear up: In the following code I have 2 issues:

  1. SPClientTemplates.TemplateManager.RegisterTemplateOverrides() expects an object. Where can I find a complete list of the keys and what I can expect them to do?

  2. Where did RenderItemTemplate come from? After sifting through a number of examples, I just happened to come across RenderItemTemplate. It isn't associated with an object, so there could be a whole bunch of helpful global functions that I know nothing about.

    function () {
    
      var itemCtx = {};
      itemCtx.Templates = {};
    
        itemCtx.Templates.Header = HeaderOverrideFunc;
        itemCtx.Templates.Item = ItemOverrideFun;
        itemCtx.Templates.Footer = FooterOverrideFunc;
    
      SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
    
    })();
    
    
    function ItemOverrideFun(ctx) {
      if (ctx.ListTitle != "My List") {
         return RenderItemTemplate(ctx);
      }
      return "<li style='background-color: #52D017;width: 300px;height: 24px;'>" + ctx.CurrentItem.Title + "</li></span>";     
    }
    
0

1 Answer 1

3

Unfortunately there isn't a lot of good documentation from Microsoft.

There are a couple good articles here:

Client Side Rendering: List Views

Client Side Rendering: List Forms

As well as all the answers to this question:

Client-Side Rendering/JS Link documentation?

The first article linked should give you a good overview of the object RegisterTemplateOverrides() expects.

The RenderItemTemplate(ctx) method may be one of the ones that is exposed/available from the SharePoint rendering system. A lot of the default stuff is available to use from within your rendering override code, it's just (again) not well documented so you will have to either look through clienttemplates.debug.js yourself, of set up a breakpoint and inspect the ctx object in a browser.

Here's an answer that lists a lot of the available default rendering methods:

https://sharepoint.stackexchange.com/a/112940/8992

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