3

I need to add a custom JavaScript link to my SharePoint list, so it would only affect that list. I don't need to add it to any other forms. How could it be done?

I was thinking, if to change .aspx file, where the list sits (if it is possible), if this is a good idea, then where can I find that file?

EDIT: I need this to pin my top row (column names) to top of browser view, so I wouldn't lose them, when user scrolls to bottom of page.

5
  • Why do you need that? This could help to brind you an answer. Commented Apr 7, 2016 at 12:54
  • Edited my question
    – Taurib
    Commented Apr 7, 2016 at 12:58
  • 3
    JSLink or adding a script editor on the views .aspx page are good ways for doing this Commented Apr 7, 2016 at 13:00
  • How to I add script editor to my view in list. When I try it through designer, then it won't change anything
    – Taurib
    Commented Apr 7, 2016 at 13:07
  • 1
    if you want to change the display of the data, you surely want check CSR Client-Side Rendering, see this link for more information. Commented Apr 7, 2016 at 13:49

5 Answers 5

3

You might do as follows from the browser:

  • Edit the list page from top right gear/edit page
  • Add new web part/Script Editor to the page
  • Add your javascript code
1
  • Oh yeah, thanks! Forgot to look for edit page from there at all..
    – Taurib
    Commented Apr 7, 2016 at 13:12
3

I usually use either a script editor web part or a content editor web part.

If you want to create sticky headers in a SharePoint list, I've been using the below library and have been pretty happy with the results.

http://spoodoo.com/sticky-headers-in-sharepoint-2013/

All you have to do to implement is throw a copy of the sticky headers js file and a copy of jQuery in a script editor above the list view and you'll magically have a fixed header when you scroll the list view.

1
  • Thanks for the answer, I was looking at the same solution! :)
    – Taurib
    Commented Apr 7, 2016 at 13:15
3

The "CEWP" approach is Ok. But you need to remember that EVERY LIST VIEW creates a "new" .aspx page.

So, "AllItems.aspx", will receive a CEWP with you JS. Your list have a "MyItens.aspx" view? Another CEWP.

Be aware of this point and good luck!

0
2

1) Edit the page of the view

2) Add a Content Editor Web Part

3) Link this CEWP to a file containing JavaScript and CSS

4) Store this file in a SharePoint Document Library

Sample: https://ybbest.wordpress.com/2013/01/15/how-to-use-html-and-javascript-in-content-editor-web-part-in-sharepoint2010/

2
  • Thanks for the answer, forgot about edit page under gear symbol
    – Taurib
    Commented Apr 7, 2016 at 13:14
  • 1
    Steps 3 and 4 are very importante to separate the code and easy editing. Commented Apr 7, 2016 at 13:15
0

Given the response William — use C# job to programmaticaly get all list views and add CEWP for each. CEWP must reference your javascript file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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