You Are Here:   Guide To Porteo Intranet Separator Skip Navigation LinksFAQs

​​ JSLinks FAQs


JSLink is nothing but one of the many mechanisms in Client Side Rendering. It is a property available on many SharePoint objects, including Fields, Lists, Views, and Content Types. In its simplest form, the JSLink property simply adds a JavaScript file to the page. Depending on the JavaScript, this could then do anything – either related to the object of which it was attached, or something completely irrelevant if desired.

CSR (Client Site Rendering) is a term for when the data is transformed using the client rather than the server. This means using client-side technologies, such as HTML and JavaScript. It allows us to style SharePoint elements using JavaScript, rather than having to write XSLT. You can use it to style complete List Views, Fields, Search Results and more.

Code samples: https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a 

How CSR works

Unlike previous SharePoint rendering systems (XSLT in 2010 and CAML in 2007), CSR is client-side. The only thing server-side webparts do is they put a huge bulk of raw data into the page, in JSON format. This data become JS object when the page loads, and from then on the Client Side Rendering begins. 

So basically, what CSR does is it gets the JS object with raw data as input, and renders huge HTML string based on it: 

 json-to-dom-eng.png

After HTML string is fully formed, it is inserted into the DOM.

CSR processing of the raw data is divided into stages, each represented by one overridable JS function. Each function returns its own chunk of HTML. Stages are often nested into each other. The stages order for list views is the following: 

 templates2.png

Group, Item and Field functions can be called many times, while View, Header, Body and Footer are called only once. 


 

Still have questions? We’re happy to help!