Tuesday, September 10, 2013

JSLink in SharePoint 2013

JS link is a new WebPart property in SharePoint 2013. It allows us to create the client side rendering solutions in SharePoint 2013. We can format the data and functionality in the WebPart. We can edit the fields and format the data and functionality with in the WebPart using JSLink.

We can override the title column using the JSLink. We can use the Javascript file. In SharePoint 2010 we can use XSLT in SharePoint designer to add extra link. Through JS we can reuse the javascript file in other webparts also as per the requirement.
Add a Javascript file in _Catalog/masterpage that we have created. And we need to add the code below in the javascript file. And we need to add the javascript reference in webpart.
We have to add the js code below,

(function () {
 var context = {};
context.Templates = {};    

context.Templates.Fields = {
  'Title': { 'View' : '<a href="<#=ctx.CurrentItem.FileRef#>"><#=ctx.CurrentItem.Title#></a>' }


We can work with JSLink as this as shown the URL.

Share this