3

I'm following this tutorial on how to use JS Link to do some custom formatting to my list views. And it is working well.

However when I go into my document sets the contents of the document set are not showing in a list view web part they are in a document set contents web part and it doesn't have a JS Link property.

Is there any way to add the JS Link to that web part? Or some other way to customize the view of my document set contents?

2

You can add the document library itself as a Web Part and it will give you a little more control, including toolbar settings and JSLink. I've found that it will filter down to contents of the document set automatically instead of showing the top level files in the document library.

This is something you would want to set at the document library level on each of the inherited content types.

0

Off the top of my head I can think of a couple ways:

  • Pull in the rendering script using the JSLink property of some other object, for instance, a Content Type, or a Field that will always be shown. This would require either having Powershell access to be able to set the property on something that already exists in the site, or you would need to be defining the Content Type or Field in VisualStudio. JSLink is a new attribute you can use declaratively in Field & Content Type definitions.
  • Add a script editor or content editor web part to the Document Set welcome page, and embed or link to the rendering code there. You do not have to use the JSLink property for CSR overrides, it just happens to be a really handy way to ensure that a JavaScript file always gets loaded with something you always want it loaded for.

Here's another great resource for learning about CSR, that also mentions the fact that you do not need to use the JSLink property to load the script.

http://www.codeproject.com/Articles/620110/SharePoint-Client-Side-Rendering-List-Views

All that being said, the question in my mind now is: does the Document Set Contents web part even use the Client Side Rendering framework to render itself?

  • We don't have access to Powershell or Visual Studio. So that tip wouldn't work in this situation. Interesting idea about using some other webpart. One other problem we are working on is that we don't want the custom tenderer to work every webpart on the page, just the one it is attached to. So that second idea might interfere with the fix we found for that. n8d.at/blog/bind-jslink-overrides-to-certain-web-parts-only – Rothrock Feb 17 '16 at 23:12
  • Right, but do you have more than one webpart on the Document Set welcome page? If so, another workaround for that issue can be found here: myfatblog.co.uk/index.php/2013/09/… Keep in mind though that this solution relies on finding the WPQ# IDs that SharePoint assigns automatically when you add webparts to a page, so if you add or remove webparts, it may break the connections and you will have to set it up again. – Dylan Cristy Feb 17 '16 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.