Saturday, 17 November 2012

The New "SPField.JSLink" property in SharePoint 2013

A New property "JSLink" of SPField has been Introduced in SharePoint 2013 with which you can now Control the Rendering (the presentation and validation) of any SPField (Custom or Out-of-box). 

You can Control the Rendering of any field in the List form and in the Views simply via assiging Custom JavaScript to the SPField.JSLink property of the that field."SPField.JSLink" property lets you specify any external JS file Containing any Client Rendering logic for a field type.

This property is available for Out-of-box Listview\Dataview webparts Where you simply set the property without modifying the webpart in SharePoint designer.So In addition to “Xsl Link” (Used to apply an external XSL to the listview webpart) that was available in Webpart properties in previous versions of SharePoint, you now have another option called “Js Link” where you can refer External JavaScript file to be used for the listview webpart. Just to be clear by external I mean a separate file not within the listview webpart. This can be uploaded to your Site asserts library or anywhere in your SharePoint site.

Edit the Listview Webpart's properties with “Edit Web Part” as shown in picture below.

Next in Webpart properties on right expand the last section “Miscellaneous” and scroll down. You would find “Js Link” as last option in Miscellaneous section.

Ads by Google

1 comment:

  1. There's a LOT more to dig into with JS Link and the Client-Side Rendering (CSR) topic in SharePoint. I'm only scratching the surface in my post, but it should get you past some of the hurdles to a 'hello world' like solution.

    Wes Preston
    Microsoft SharePoint MVP