SharePoint 2013 Customize View

2

July 23, 2013 by Ravi C Khambhati

Here is the new post after a long time.

While I was working on the SharePoint 2013 I came to know very interesting Client Side Rending approach.

Follow below steps to customize the view,

1. Identify the view and edit JSLink property of view with the custom js file. For e.g. customclienttemplates.js. You can do this either with schema file or SharePoint Manager 2013

SharePoint.List.SchemaFile

SharePoint.List.SchemaFile

2. Edit customclienttemplates.js with below content. This script will edit title column to hyperlink and will redirect to view page.

(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = { 'Title': { 'View': TitleBody } };
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);}
)();
function TitleBody(ctx) {
    var ret = "<a href='" + ctx.displayFormUrl + "&ID=" + ctx.CurrentItem.ID + "'>" + ctx.CurrentItem.Title + "</a>";
    return ret;
}

3. Do IISreset

4. Navigate to list view

Apart from this solution I would like to give you some tips,

If you would like to do more customization you can debug JavaScript with Visual Studio and you can see more properties.

Below is the image of ctx watch

SharePoint.Context.Watch

SharePoint.Context.Watch

Same way you can watch of ctx.CurrentItem and see all properties.

I would like to thank to “Jussi Palo” to understand the concept.

http://blog.jussipalo.com/2013/05/sharepoint-2013-linking-item-titles-to.html

Google+

Advertisements

2 thoughts on “SharePoint 2013 Customize View

  1. manishrao18 says:

    Very nice article, with good details. Happy sharepointing 🙂
    Regards,
    Manish Patil

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: