1

I have a problem using JSLink. The goal is to color in red, orange, green the priority field. For information, I followed step-by-step the tutorial given by Microsoft.

  1. In Site Features, I've ACTIVATED the 'SharePoint Server Publication'

  2. In Site Settings, I click on 'Master Page'. It send me to the master page gallery (on site collection). I added my .js, following this tutorial, with the following information:

    • JavaScript display template
    • target type = View
    • standalone = Override
    • target scope = /site_collection/etc/etc/mysite/mylistview.aspx

    And finally 'Publish' to validate.

  3. In my list view, I click to modify the web part, and under Miscellaneous, in JS field, I add the link to the JS file in the masterpage. Ie, /site_collection/etc/masterpage/colorpriority.js

  4. After that, I close the file, but nothing happens !

  • If you edit the web part after setting the JSLink property, does it stick? Or does it revert? If it sticks, try running IE Dev tools when loading the page, and see if any errors are occurring. And can you share code? – wjervis Aug 4 '15 at 12:34
  • Also, just to speed up your CSR efforts, use Cisar by Andrei Markeev. You'll get instant results with that. – Akhoy Aug 4 '15 at 14:17
  • Link to extension that @uberz91 mentions – wjervis Aug 5 '15 at 11:47
  • Can you mark the question as answered, tom, Keeps StackOverflow clean – Danny '365CSI' Engelman Aug 14 '15 at 10:30
2

It is

~sitecollection/etc/masterpage/colorpriority.js

You have

/site_collection/etc/masterpage/colorpriority.js

Must read for all CSR developers:

http://spdevlab.com/2013/07/07/5-facts-about-jslink-in-sharepoint-2013-you-might-not-know/

Alternative: Color using a Calculated Column

FYI, You can also Color based on Priority using a Calculated Column
No need for Scriptfiles & JSlink

Create a Calculated Column, set datatype to Number

=[Priority]
&IF([Task Status]="Not Started" , "" ,
  "<img src=""/_layouts/images/blank.gif"" onload=""{"
    &"var row=this;while(row.tagName!='TR'){row=row.parentNode}"
    &"row.style.backgroundColor='#"
    &CHOOSE( RIGHT( LEFT( [Priority] , 2) , 1) , "fab" , "fda" , "9fa" )
  &"'}"">" 
)

Detailed explanation at: http://www.viewmaster365.com/#/How

  • 1
    ~sitecollection/etc – Anders Aune Aug 4 '15 at 13:21

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.