JS Link and CSR (Client-Side Rendering) for SharePoint 2013 are often used interchangeably, but they aren’t exactly. The JS Link web part property is a way to add CSR template overrides to your page.
I’ve got a longer post on more of the details and use of JS Link for CSR in SharePoint 2013, but this is a quick ‘Hello World’ version for JS Link. There are three main components:
This file, saved as [yourFileName.js] literally only needs to have a single line:
- Put the file in a location where your JS Link reference can see it.
- One common location to upload to is the Master Page Gallery though other locations can be used. This does require higher permissions on the site, however.
- Using this ‘Hello World’ approach is a great way to test the location of your file, the permissions to that file and the JS Link string (next step) used to get everything working.
You are changing the properties of a web part here. Technically you can edit the web part of a standard view for a list, but I generally don’t do that.
- For this example create a page on the site and drop a web part from your test app (list or library) on to that page.
- Edit the page and Edit Web Part. At the far bottom of the web part properties, under the Miscellaneous grouping is the ‘JS Link’ property.
- Enter the following and click OK.
Now, you can start playing with CSR or other functionality with the JS Link. Check out my Primer post… more examples are coming shortly.